In this article, we will see –
- how to deploy Azure WebApp,
- add deployment slot,
- code push to Production and Staging slots
- finally, swap the slots
Design and Architecture of Azure Web App Deployment slots is given on the link below –
Deploy Azure WebApp
- Login to Azure Portal – https://portal.azure.com
- Deploy Azure WebApp using the New menu
- Click on Azure WebApp once it is created, click on “Deployment slots” and then click on “Add Slot”
- I have slot as “Staging”, and I have chosen not to clone configuration from Production slot. This is being done because we will be deploying different version of the app into both slots.
Production URL – http://sarveshgoel.azurewebsites.net
Staging Slot URL – http://sarveshgoel-staging.azurewebsite.net
Push code to Production and Staging deployment slots
- Launch VSTS and open sample web code. I have update the heading on the page to show – Production text. This will be published to the Production slot. Right click on the solution and click on Publish
- Select new profile, select Azure App Service. Choose Select Existing since we will be deploying to existing Azure WebApp
- Select the Primary slot – sarveshgoel and the code will be pushed there. We will run similar steps for Staging slot.
- Now click on Publish, and wait for the confirmation.
- Now browse the URL – http://sarveshgoel.azurewebsites.net and you would see the changes that we did initially
Deploy to Staging Slot now
Now repeat the process for Staging Slot but remember to modify the content of Web page, for example – I would change Production to Staging. Another change will from the steps above to deploy to Staging slot
Swap the Azure WebApp Deployment slot now
Now we have two versions of Web Application running on separate slots, running on their own Web URLs. As explained in the Design and Architecture documentation, purpose of staging slot is to test the code before making it Production.
Please remember, the slots in Production WebApp should be used for Staging environment but not for QA or testing environments.
Now, click on deployment slots on the Azure Portal, click on Swap . Now swap Production with Staging as shown below.
Once you click on Ok, Production becomes Staging and Staging becomes Production within few seconds.
Look at the URLs above, and try using this amazing feature Azure WebApp deployment slot.