Slot settings
App Service deployment slots and sticky slot settings: --slot-settings, what swaps and what stays, swap with preview, and container image swaps.
What this covers
Deployment slots let you run different versions of an app side by side in the same App Service plan. Each slot has its own hostname and configuration but shares the plan's compute. A swap promotes staging to production with no downtime. Some settings must stay with the slot rather than move with the code during a swap, and you mark those as slot settings (also called sticky settings).
Exam weight: Develop containerized solutions on Azure (20–25%)
Skills measured
- "Deploy containers to Azure App Service, including configuring App Service to supply environment variables and secrets"
Key concepts
Slots
- Available on Standard (5 slots), Premium and Isolated tiers. Slots cost nothing extra.
- A new slot starts with no content. You can clone settings from another slot.
- For containers, the image reference is part of what swaps, so staging's image becomes production's image.
Why sticky settings matter
| Category | Example |
|---|---|
| Environment identifiers | ENVIRONMENT=production must not swap to staging |
| Environment-specific endpoints | Different API or DB targets per slot |
| Feature flags | Turn on experimental features only in staging |
| Diagnostics | Verbose logging in staging only |
| Key Vault references | A separate vault per environment |
What swaps and what stays
| Swaps (follows the content) | Stays with the slot |
|---|---|
| App settings and connection strings not marked sticky | Settings marked as slot settings |
| Framework/runtime, container image, WebSockets, handler mappings | Custom domains, nonpublic TLS certs, scale settings |
| Mounted storage (unless sticky) | Managed identities, VNet integration, IP restrictions, Always On, CORS, diagnostic log settings |
Swap sequence
- Production's sticky settings are applied to the staging instances, which restart.
- Staging is warmed up (HTTP request to
/, orWEBSITE_SWAP_WARMUP_PING_PATH). - Routing switches. Production never goes offline.
- To roll back, swap again.
Swap with preview pauses after step 1 so you can test staging with production settings. Auto swap isn't supported for Linux apps or Web App for Containers.
How it works
Hands-on
Azure portal
- On the web app, open Deployment > Deployment slots and select Add slot (for example
staging). - In the staging slot, open Settings > Environment variables, add
ENVIRONMENT=staging, and select Deployment slot setting. - Back on Deployment slots, select Swap. Review the Source slot changes and Target slot changes tabs, then Start swap.
Azure CLI
Mark settings as slot settings:
az webapp config appsettings set \
--resource-group myResourceGroup \
--name myDocumentProcessor \
--slot staging \
--slot-settings \
ENVIRONMENT=staging \
API_ENDPOINT=https://api-staging.example.comList the sticky settings:
az webapp config appsettings list \
--resource-group myResourceGroup \
--name myDocumentProcessor \
--query "[?slotSetting==\`true\`].name"Create, deploy to and swap the slot (with preview):
az webapp deployment slot create -g myResourceGroup -n myDocumentProcessor --slot staging
az webapp config container set -g myResourceGroup -n myDocumentProcessor --slot staging \
--container-image-name myregistry.azurecr.io/docprocessor:v2
az webapp deployment slot swap -g myResourceGroup -n myDocumentProcessor \
--slot staging --target-slot production --action preview
az webapp deployment slot swap -g myResourceGroup -n myDocumentProcessor \
--slot staging --target-slot production --action swapPython
from azure.identity import DefaultAzureCredential
from azure.mgmt.web import WebSiteManagementClient
client = WebSiteManagementClient(DefaultAzureCredential(), "<subscription-id>")
names = client.web_apps.list_slot_configuration_names("<resource-group>", "myDocumentProcessor")
print("Sticky app settings:", names.app_setting_names)Exam traps
| Requirement | Answer |
|---|---|
| Value must not move to production on swap | --slot-settings (sticky) |
| Value should travel with the new release | --settings (swappable) |
| Test staging with production config before switching | Swap with preview (--action preview) |
| Undo a bad release | Swap again |
Quick review
- Slot settings stay with the slot during a swap.
- CLI:
--slot staging --slot-settings KEY=value. - List sticky settings with
[?slotSetting==\true`].name`. - Good sticky candidates:
ENVIRONMENT, environment-specific URLs, feature flags, log verbosity, Key Vault references. - Slots share plan resources but not sticky configuration.
- Use cases: a staging slot pointing at a test model endpoint, verbose
LOG_LEVELonly in staging, blue/green promotion of an inference image.