DEV Community

Cover image for How to Use Deployment Slots in Azure App Service for Zero-Downtime Updates
Olalekan Oladiran
Olalekan Oladiran

Posted on

How to Use Deployment Slots in Azure App Service for Zero-Downtime Updates

Introduction

Deployment slots in Azure App Service enable zero-downtime updates and risk-free testing by providing isolated staging environments that mirror your production app. In this guide, you’ll learn how to:

  • Create deployment slots (and upgrade your App Service plan when needed)
  • Deploy changes to a staging slot for validation
  • Swap slots seamlessly to promote tested code to production
  • Verify the swap while maintaining rollback capability
  • Perfect for CI/CD pipelines or manual deployments, this approach minimizes downtime and ensures smoother releases. Let’s dive in!

Requirements

Configure Deployment Slot

  • Open your Azure App services and select Deployment Slot under Deployment section. Image description
  • Since deployment slot is not supported by shared service plan, it will ask you to upgrade to standard or premium. Image description
  • Click upgrade, choose standard S1 and click on Select Image description
  • Click Upgrade Image description
  • Go back to deployment and click Add slot Image description
  • Choose a name for your slot which will serve as a unique url for your slot. Click Add after Image description
  • Confirm that the slot is created Image description
  • Open the slot by clicking on it. Click the Default Domain of the staging slot to check if it is running. Image description Image description
  • You need to push your development code to this staging slot and see how you can swap it with the production after testing.
  • Head over to VS Code and make some changes to the index.html file. I added version 2.0 to distinguish it from the production slot Image description
  • Next is to deploy it to slot by clicking view and select command pallete. Repeat the steps used to deploy the production slot
  • Search and select Deploy to slot Image description Image description Image description Image description Image description Image description Image description
  • After deployment is succeeded, go back to the browser and click on refresh. Image description

Swap deployment Slot

This allow seamless transition between production and staging environment

  • Go back to your production slot and click on swap. Image description
  • Leave the settings as default and click start swap and wait for the swap to finish. Image description
  • To check if the swap works, go to your production Default Domain and it should display app with version 2.0 Image description
  • Staging will display app without version 2.0 Image description

Thanks for staying till the end

Top comments (0)