Last updated: May 2026
Azure App ServiceIntermediateAZ-104⏱ 12 min read

Deployment Slots

Deployment slots are live web apps with their own hostnames. They let you deploy new code to a staging environment, test it with production-level traffic patterns, then "swap" it into production with zero downtime. If something goes wrong, you can swap back just as quickly. Deployment slots are one of App Service's most powerful features — enabling safe, zero-downtime releases.

What you'll learn What slots are and how they work · Creating and managing slots · The slot swap process in detail · What gets swapped vs what stays · Slot settings (sticky settings) · Traffic splitting for A/B testing · Auto-swap · Swapping with preview · Slot limits by tier

What Are Deployment Slots?

Each deployment slot is a fully independent App Service instance with its own:

  • Hostname: myapp-staging.azurewebsites.net
  • App settings and connection strings
  • Deployment source configuration
  • Application code

Slots run on the same App Service Plan as the production slot — sharing compute resources. The production slot is always named "production" (accessible at myapp.azurewebsites.net).

ℹ️
Slots Count by Tier Standard: 5 slots total (production + 4) · Premium v3: 20 slots total · Isolated: 20 slots total · Basic: 0 slots (no slots supported)

Creating Slots

Azure CLICreate a staging slot
# Create a staging slot
az webapp deployment slot create \
  --name mywebapp-2026 \
  --resource-group myRG \
  --slot staging

# Deploy to staging slot (not production)
az webapp deploy \
  --name mywebapp-2026 \
  --resource-group myRG \
  --slot staging \
  --src-path myapp.zip \
  --type zip

# List all slots
az webapp deployment slot list \
  --name mywebapp-2026 \
  --resource-group myRG \
  --output table

The staging slot is accessible at: https://mywebapp-2026-staging.azurewebsites.net

The Swap Process

When you swap slots, App Service:

  1. Warms up the source slot — Applies target slot's settings to source, restarts it, sends warm-up requests until it responds
  2. Switches routing — Updates the host name routing atomically — source becomes target, target becomes source
  3. Post-swap — Old production is now in the staging slot, ready for rollback if needed
💡
Zero Downtime The swap is atomic — there's no moment when neither slot is serving traffic. Users experience no interruption. Existing connections complete normally in the old slot while new connections go to the new production.
Azure CLISwap staging to production
# Swap staging slot to production
az webapp deployment slot swap \
  --name mywebapp-2026 \
  --resource-group myRG \
  --slot staging \
  --target-slot production

# Rollback (swap back)
az webapp deployment slot swap \
  --name mywebapp-2026 \
  --resource-group myRG \
  --slot staging \
  --target-slot production

What Gets Swapped vs Stays

Understanding what moves with the slot vs what stays is critical — it's frequently tested in AZ-104.

Gets Swapped (moves with code)Stays (not swapped)
Application code/contentSlot-specific app settings (sticky)
General app settings (non-sticky)Slot-specific connection strings (sticky)
Connection strings (non-sticky)Custom domain bindings
Handler mappingsTLS/SSL certificates and bindings
WebJobs contentScale settings
Public certificatesWebJob schedulers
Always On settingIP restrictions

Slot Settings (Sticky Settings)

By default, App Settings and Connection Strings swap with the code. But sometimes you want a setting to stay in its slot — for example, a connection string that should always point to the production database regardless of which code is deployed.

Mark a setting as a Slot Setting (also called "sticky") to prevent it from swapping. Common examples:

  • Production database connection string — should always point to prod DB
  • Environment name variable (ENVIRONMENT=production)
  • Third-party API keys that differ between environments
Azure CLIMark a setting as slot-specific (sticky)
# Set a sticky app setting
az webapp config appsettings set \
  --name mywebapp-2026 \
  --resource-group myRG \
  --slot staging \
  --slot-settings DATABASE_URL=staging-connection-string

Traffic Splitting

Traffic splitting (also called Testing in Production) routes a percentage of real user traffic to a non-production slot — useful for A/B testing or canary releases.

  • Configure a percentage (e.g., 10%) to route to staging
  • Users are sticky — once assigned to a slot, they stay there for the session
  • Azure adds an x-ms-routing-name cookie to track which slot a user is in
Azure CLIRoute 10% of traffic to staging
# Route 10% of traffic to staging slot
az webapp traffic-routing set \
  --name mywebapp-2026 \
  --resource-group myRG \
  --distribution staging=10

Auto-Swap

Configure a slot to automatically swap into production whenever new code is deployed to it. Enables fully automated zero-downtime deployment pipelines.

  • Enable Auto-Swap on the staging slot
  • Set the target slot (usually production)
  • After each successful deployment to staging, App Service automatically swaps to production

Swap with Preview

A two-phase swap for extra safety:

  1. Phase 1 — Apply production's slot settings to staging, restart staging. Preview the result at the staging URL with production settings.
  2. Verify — Test that staging works with production settings.
  3. Phase 2 — Complete the swap — routing switches to the staged code.
💡
AZ-104 Exam Tip This is heavily tested. Know that Standard tier minimum is required for slots. Know that sticky settings don't swap. Know that swapping is instant and zero-downtime. Know that the old production code ends up in the staging slot after a swap — enabling rollback by swapping again.
📝 Practice Questions
Click an option to check your answer.
Q1. After swapping staging with production in App Service, where is the old production code?
A — It is deleted
B — It is now in the staging slot — enables instant rollback by swapping again
C — It is archived in Azure Blob Storage
D — It remains in production alongside the new code
Q2. A database connection string is marked as a "slot setting" on the production slot. What happens to this setting during a slot swap?
A — It swaps to the staging slot along with the code
B — It stays in the production slot and does not swap
C — It causes a deployment error during the swap
D — It is deleted after the swap
Q3. What is the minimum App Service Plan tier required to use deployment slots?
A — Free (F1)
B — Basic (B1)
C — Standard (S1)
D — Premium (P1v3)
Q4. What does traffic splitting in App Service enable?
A — Load balancing across multiple instances of the same slot
B — Routing a percentage of real user traffic to a staging slot for A/B testing or canary releases
C — Distributing traffic between different Azure regions
D — Mapping multiple custom domains to the same app
Q5. What is Auto-Swap in App Service deployment slots?
A — Automatically reverts a deployment if the application health check fails
B — Automatically swaps a slot to production after each successful deployment to it
C — Automatically scales out instances when traffic increases
D — Automatically creates new slots when existing slots are full
Comments
Disclaimer: RedKite Cloud is an independent educational resource and is not affiliated with Microsoft Corporation.