Blue-green releases with deployment slots
In this task you'll release to a staging slot and swap it into production.
A deployment slot is a second copy of the web app with its own address. Deploy and warm up the new version there, then swap: production switches instantly, and swapping back is the rollback.
Settings marked as slot settings stay with their slot; everything else moves with the code.
Example. Ironbridge Payments deploys to staging, runs smoke tests against its address, then swaps; a bad release is undone by swapping again in seconds.
Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.
Before you start
You need: An App Service plan on Standard, Premium or above. Time: 20 minutes.
Where to look
- Home
- App Services
- (app)
- Deployment
- Deployment slots
Steps
az webapp deployment slot create -n <app> -g <group> --slot staging --configuration-source <app>.- Deploy or configure v2 in the staging slot and test https://<app>-staging.azurewebsites.net.
- Mark environment settings with
--slot-settings. az webapp deployment slot swap -n <app> -g <group> --slot staging --target-slot production.
Commands
az webapp deployment slot create -n <app> -g <group> --slot staging --configuration-source <app>
az webapp config appsettings set -n <app> -g <group> --slot staging --slot-settings DEPLOY_SLOT=staging
az webapp deployment slot swap -n <app> -g <group> --slot staging --target-slot production
Watch out for
- Cost
- Slots need Standard or Premium: Premium v3 P0v3 is about 7p an hour. On our trial only one P0v3 was allowed per region.
- Security
- Staging is public by default: add access restrictions.
- Common mistakes
- Settings that should be sticky (connection strings to the right database) moving with the swap.
Clean up
Delete the slot (az webapp deployment slot delete) or the resource group.
Words to know
- Slot
- A live copy of the app with its own host name.
- Swap
- Exchanging the content and configuration of two slots.
- Slot setting
- A setting that sticks to its slot during a swap.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On