Deployment slots in Azure App Service help you to deploy new features of your app without any downtime. Let's see how we can do that with a containerized application. We'll start with an ASP.NET app that is already containerized and deployed to an Azure App Service.
In Visual Studio,right-click the project fileand clickPublish
In the Publish window, change theImage Tagto something else than "latest"
ClickPublishto publish the new version of the application in a container to the container registry
Publish window in Visual Studio
Go back to the Azure portal and back to the App Service
Select theDeployment slotsmenu
We currently have no deployment slots, so let's add one by clicking onAdd Slot
Provide anamefor the deployment slot
You'll now see the new slot in the list of deployment slots. Click on it
When the deployment slot is opened, it looks exactly the same as the App Service. That is because a deployment slot is another instance of an App Service that runs in the sameApp Service Plan. This means that you can use almost all App Service features in a deployment slot and that you don't pay extra for it. Go to theContainer settingsmenu in the deployment slot
In Container Settings, change theFull Image Name and Tag, so that it points to the latest version of the application
Go back to theOverviewblade and clickRestartto restart the App Service. Now wait a few minutes and clickBrowseto see the new version of the app in action
New version of the app in a deployment slot
The new version of the application runs in a deployment slot. The slot has almost the same URL as the original App Service (theproductionslot), only appended with the slot name, likecontainer-tricks-staging.azurewebsites.net
Now for the magic part of deployment slots, the swap. Go to theDeployment slotsmenu again
Click on theSwapbutton
Leave everything as it is and clickSwap. This will warm up the staging slot and "swap" it with the production slot, to seamlessly deploy the new version of the application to production, without any downtime
Swap deployment slots
In the Deployment slot blade, click on theproduction slot
Click onBrowsein the overview blade to see the app that is running in production
New version of the app in production
The latest version of the app is now running in production. If you check the deployment slot, you'll find that it is now running the old version of the app. This allows you to easily revert a deployment, by simply swapping back.