Create a project on VSTS
Name the project and add description. Also choose the Git as your version control type.
The project will be create and you will have option to push code or import existing repository.
Select import a repository and Clone URL https://github.com/krishnaji/lets-chat.git
In search box find and add following tasks.
- npm
- grunt
- Archive files
- Copy and publish build Artifacts
Rename the build letschat-CI and select the Agent as Hosted VS2017
Now we have to configure each task. Lets start with npm. Set npm task as shown in image.
Set Grunt task as shown in image
Set up Archive Files task as shown in image below.
Setup the Copy and Publish task as show in image below.
Now save(only) the build definition. Do not queue for now.
Select / as your save build definition folder.
Now its time to queue the build.
Select Agent as Hosted VS2017
You can view the running build.
You should see running tasks.
Once the build is completed you should see Build Succeeded message.
Now lets create a release.
Rename the release definition name.
Add artifact by selected Add artifact.
Now add new environment
Name it Stage
Click Add dropdown and clone the environment.
Name the new cloned environment as Production
Add variables. These will be used in Stage and Production task configuration
Add two variables as shown below. Select Release as Production and Stage for respective variables. Note the website name is set to your app service name and stage is the Stage slot.
Now select Stage Task and add Azure App Service Deploy task. Refer below image.
We will first deploy the app to the slot named Stage.Configure the app service deploy task. Select the Azure subscription and Authorize it. Seet the app service name as the variable that we created. Also check the Deploy to slot box. Note: If you get error, open VSTS link incognito or private browsing mode and create Azure Resource Manger Endpoint. Please refer this link
Now select Production task and configure it to swap the production and stage slots. Save it.
Create a new release.
Select all environments.
Visit the release
Deploy Stage manually.
You should refer the logs for details about the release task execution.
The Stage should be successful. Once done you can browse http://<WebAppName>-<SlotName>.azurewebsites.net
stage app.
Now like stage Deploy the the Production. Once its done you should see the slots are swapped. Visit http://<WebAppName>.azurewebsites.net
to verify it.
Edit build defition and enable the Continuous integration trigger.
Edit build defition and enable Continuous deployment trigger.
Before swapping the Stage with production we need to add an approval. So that we can verify that Stage is working fine and only after approval the swap should happen. Add post stage deployment condition. Approval. You will get notification for approval.
Finally add settings.yml file and commit changes to vsts git repository. You should be able to see that new build is triggred and running.