Azure App Services — Deployment Slots

theUnixe
5 min readJan 27, 2024

--

Hello Hacker !!

Today i am going to sharing my learnings, about Azure App Services Deployment Slots.

Let’s dive into the topic.

Deployment Slots is a feature offered by Azure App Services, which allows you to create separate environments for deploying and testing your Web App, before making the app available to all the end users. Each Deployment Slot represents a separate instance of your app, which can be used for various purposes such as staging, testing or production. In this article, I present the benefit of this feature and how to use it.

Deployment Slots offer a good strategy to manage and deploy multiple versions of your app simultaneously. This capability allows you to have distinct environments, where you can run different versions of your app concurrently. With this approach, you can release a new version of your app in one environment, while keeping the latest version in another environment.

Creating Deployment Slots in Azure App Services

To demonstrate how to work with Deployment Slots, I created a simple ASP.NET Application and I’m going to deploy it to an App Service.

Note that in order to use Deployment Slots feature, the App Service Plan must be Standard or higher.

In Azure Portal, go to the App Service and select the “Deployment slots” menu:

As it shows, at this moment there is only the App Service that can be selected in the publish window, this is the single Deployment Slot that we currently have, for Production. So let’s use this one to deploy the .NET Web Application to the App Service, using Visual Studio:

Then click on “ Finish &Publish”:

This is the application running in the App Service:

Let’s create a new Slot, for that, go to the App Service and click on “+ Add Slot”, add a name and select the option to clone the settings from the current app (attention: if you want to have a separate stage environment, you should have a specific settings for it):

Now you should see two slots:

We can also configure the percentage of the route traffic that we want to direct to each environment. On the deployment slot page, you can update the Trafic percentage. This way each access to your app can be redirected to the production or the stage slot:

I’ve made a change to the app, so now we have the app version 2:

Now, in the publish window in Visual Studio, you will be able to select the newly created slot, to deploy your app:

In case you want to deploy to the production slot, just select the App Service, instead of selecting the deployment slot.

After publishing the app, open a new browser window and access the app using the domain appservicesdsdemo.azurewebsites.net, and you can be redirected to the newly deployed version or to the previously deployed version (access the URL on diff pages and you can be redirected to diff versions):

Specific domain for different slots

Deployment Slots also provides a specific URL for the specific slots, so in case you only want to access the app deployed on stage for example, you can always access it by using the stage app domain. To check it, go to the deployment slots page and select the stage slot:

And access using the domain appservicesdsdemo-stage.azurewebsites.net:

Swapping the slots

Now that our app was already tested on stage, let’s swap it to the production environment. For that, go to the App Service in Azure Portal and in the Deployment slots page, click on “Swap”, double check the Source and the Target, and click on “Swap”. This will swap the deployment slots and will deploy the new app to the production slot (the swap action warms up both slots, to make sure that there is not any downtime):

Accessing the production domain, you can now see the new version deployed:

And if you access the stage domain, you can see the Version 1 that was initially deployed:

Conclusion

Deployment Slots provide you with the benefit of having great flexibility to manage and test multiple versions of your app simultaneously, providing a reliable and controlled deployment process that maximizes user satisfaction and minimizes disruptions. With this feature, you can reduce the release risks of your apps and ensure a smooth transition between the different versions of your apps.

Thank You !!!

theUnixe

Linkedin: https://www.linkedin.com/in/rahul-banik-6477a4225/

--

--

theUnixe

Penetration Tester | Ethical hacker | Cybersecurity Professional | Azure Admin