Deploying straight to production is one of the fastest ways to turn a small bug into a public outage. Azure App Service deployment slots solve this problem by giving you extra, fully functional copies of your web app that share the same App Service plan. In this guide, you will learn how Azure App Service deployment slots work, how to create a staging slot, how to warm it up and validate it, and how to swap it into production with zero downtime — plus how to roll back instantly if something goes wrong.

How Azure App Service Deployment Slots Work
Every App Service has a production slot, which is the app your users actually reach. When you add a deployment slot, Azure creates another instance of the app with its own hostname, such as myapp-staging.azurewebsites.net, while sharing the same App Service plan, region, and scaling configuration. Each slot has its own code, configuration, and deployment history, so you can test a new release in a real Azure environment without touching production traffic.
The key operation is the swap. During a swap, Azure exchanges the routing rules of the two slots, so the staging slot suddenly serves production traffic and the old production code moves into the staging slot. Because the swap only changes routing pointers — it does not copy files or restart the app from scratch — it completes in seconds and existing connections are drained gracefully. If the new version misbehaves, you swap back and production is restored just as quickly.
There is one important detail to understand: some settings are slot settings and some are shared. Slot settings, such as a staging database connection string, stay with the slot during a swap. Shared settings move with the code. Marking a setting as a slot setting is how you keep staging pointed at a staging database even after it becomes production, or vice versa. Getting this wrong is the most common cause of a bad swap, so we will configure it explicitly below.
Prerequisites
- An Azure subscription and an existing App Service (any tier that supports slots: Standard, Premium, or Isolated — Free and Shared tiers do not support deployment slots).
- The Azure CLI installed and signed in (
az login), or access to the Azure portal. - An application already deployed to the production slot, so you have a known-good baseline to compare against.
- A separate staging database or storage account, if your app uses one, so staging tests never write to production data.
Step 1: Create a Staging Slot with Azure App Service Deployment Slots
The fastest way to create a slot is to clone the production configuration, which copies app settings, connection strings, and deployment configuration. Cloning avoids the classic mistake of a staging slot that behaves differently from production simply because a setting was forgotten.
az webapp deployment slot create \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--configuration-source myapp
After the command finishes, your staging app is available at https://myapp-staging.azurewebsites.net. Verify it responds before deploying anything to it:
curl -I https://myapp-staging.azurewebsites.net
In the Azure portal, you can do the same thing under your App Service: Deployment slots > Add Slot, choose “Clone settings from” your production app, and name the slot staging.
Step 2: Mark Staging-Only Settings as Slot Settings
Open the staging slot and review its configuration. Any value that must stay with the slot — typically the staging database connection string, a staging API key, or a feature flag that enables debug logging — should be marked as a slot setting. With the Azure CLI:
az webapp config appsettings set \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--slot-settings DATABASE_URL="Server=staging-db.example.com;Database=myapp_staging" \
--settings APP_ENV="staging"
Notice the difference: --slot-settings values stick to the slot during a swap, while --settings values travel with the swapped code. As a rule, connection strings for staging resources are slot settings, and ordinary application settings are not. Double-check this list before every swap — a staging slot that points at the production database will corrupt real data during testing.
Step 3: Deploy the New Version to Staging
Deploy exactly the same artifact you intend to release to production. If you deploy from a CI pipeline, target the staging slot explicitly rather than the default production slot:
az webapp deploy \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--src-path ./myapp.zip \
--type zip
Once deployed, warm up the staging slot. App Service performs a warm-up automatically during a swap, but a manual check catches cold-start errors, missing environment variables, and broken database migrations before they matter:
curl -s https://myapp-staging.azurewebsites.net/health | head -c 500
curl -s -o /dev/null -w "%{http_code}\n" https://myapp-staging.azurewebsites.net/
Run your smoke tests against the staging hostname: log in, complete a checkout or a representative workflow, and confirm the app writes only to staging resources. If your app has a health endpoint, this is also the time to confirm it reports healthy with the new build.
Step 4: Swap Staging into Production
When staging is verified, perform the swap. This is the moment Azure App Service deployment slots are designed for: Azure first applies the production configuration to the staging slot, warms it up, and then switches routing:
az webapp deployment slot swap \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--target-slot production
Users experience no downtime: new requests go to the warmed-up staging code, and in-flight requests on the old production instance drain naturally. After the swap, immediately verify the production hostname serves the new version and check your application logs and metrics for errors.
If you use the portal instead, go to Deployment slots > Swap, select staging as the source and production as the target, and review the configuration changes preview before confirming. That preview is worth reading every time: it shows exactly which settings will change on each side.
Step 5: Roll Back Instantly if Needed
The beauty of slots is that rollback is just another swap. The previous production code is still sitting in the staging slot, untouched, so if monitoring shows errors after release, swap back:
az webapp deployment slot swap \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--target-slot production
Because the old code was already warmed up and running, rollback takes seconds rather than the minutes a fresh redeploy would need. Keep the old version in the staging slot until you are confident in the new release — do not deploy the next feature on top of it immediately.
Automating Azure App Service Deployment Slots in CI/CD
For teams that release often, wire slots into your pipeline. A typical flow is: build once, deploy the artifact to staging, run automated tests against the staging hostname, and swap only if tests pass. In GitHub Actions, the deploy step targets the slot by name, and the swap step runs only after the test job succeeds. This pattern gives you a release gate that is enforced by real infrastructure rather than by discipline alone.
Two automation tips matter in practice. First, enable auto swap only for low-risk apps: it swaps automatically after every deployment to a slot, which removes the manual verification step that makes slots valuable. Second, use swap with preview (multi-phase swap) for critical apps: it applies production settings to staging first, lets you verify that exact combination, and only then completes the routing change.
To enable swap with preview from the CLI, add the preview flag on the first command, verify, then complete it:
az webapp deployment slot swap \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--target-slot production \
--action preview
# After verifying staging with production settings:
az webapp deployment slot swap \
--name myapp \
--resource-group myapp-rg \
--slot staging \
--target-slot production \
--action swap
If you are deploying a CMS or web app on Azure for the first time, our guide to deploy WordPress on Azure App Service covers the initial App Service setup that this slot workflow builds on. For the full reference on slot behavior, settings, and swap options, see the official Azure App Service deployment slots documentation.
Troubleshooting Azure App Service Deployment Slots
Swap fails with a configuration error
This usually means a slot setting conflicts with a shared setting, or a connection string references a resource the target slot cannot reach. Review the swap preview in the portal, which lists every setting change, and fix the mismatch on the staging slot before retrying.
Staging works but production breaks after the swap
The most common cause is a setting that should have been a slot setting but was not — for example, a production API key that moved into the old production code, or a staging database string that followed the code into production. Check the production slot’s current configuration immediately after a bad swap and correct it, then swap back if needed.
Users see stale content or mixed versions after a swap
Slots share the same plan but have separate local storage unless you use external storage. If your app writes uploads to local disk, a swap will not carry those files over. Move user uploads to Azure Blob Storage or a shared file share so both slots see the same data.
Slots are not available on my plan
Free and Shared tiers do not support deployment slots. Scale up to Standard or higher — the slot itself costs nothing extra beyond the plan, so a single Standard plan can host production plus staging at no additional App Service charge.
Conclusion
Azure App Service deployment slots turn releases from a risky leap into a reversible, verifiable step, and mastering Azure App Service deployment slots is one of the highest-value skills for any team running production workloads on Azure. Create a staging slot cloned from production, mark staging-only values as slot settings, deploy and test the real artifact there, swap with confidence, and keep the old version one swap away until the release proves itself. Adopted as a habit, this workflow removes the most common cause of deployment outages: untested code reaching production for the first time. Set up your staging slot today, and your next release will be the calmest one you have shipped.