How to use Azure WebApp Deployment Slots

How to use Azure WebApp Deployment Slots

In this article, we will see –

  1. how to deploy Azure WebApp,
  2. add deployment slot,
  3. code push to Production and Staging slots
  4. finally, swap the slots

Design and Architecture of Azure Web App Deployment slots is given on the link below –

Azure WebApps – Deployment Slots Architecture

Deploy Azure WebApp

  1. Login to Azure Portal – https://portal.azure.com
  2. Deploy Azure WebApp using the New menu
  3. Click on Azure WebApp once it is created, click on “Deployment slots” and then click on “Add Slot”
  4. 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.

Summary –

Production URL – http://sarveshgoel.azurewebsites.net

Staging Slot URL – http://sarveshgoel-staging.azurewebsite.net

Push code to Production and Staging deployment slots

  1. 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
  2. Select new profile, select Azure App Service. Choose Select Existing since we will be deploying to existing Azure WebApp
  3. Select the Primary slot – sarveshgoel and the code will be pushed there. We will run similar steps for Staging slot.
  4. Now click on Publish, and wait for the confirmation.
  5. 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.

 

About The Author

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *