Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare Azure environments for new workloads—subscriptions, networking, identity, and landing zones
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/app-service/deployment-slots.md
1# App Service Deployment Slots23Zero-downtime deployments using staging slots.45## Basic Staging Slot67```bicep8resource stagingSlot 'Microsoft.Web/sites/slots@2022-09-01' = {9parent: webApp10name: 'staging'11location: location12properties: {13serverFarmId: appServicePlan.id14}15}16```1718## Slot Requirements — App Service1920| SKU Tier | Slots Supported |21|----------|-----------------|22| Free/Shared | 0 |23| Basic | 0 |24| Standard | 5 |25| Premium | 20 |2627## Slot Requirements — Azure Functions2829> ⚠️ Slot support for Azure Functions varies by OS and hosting plan.3031| Hosting Plan | OS | Slots Supported |32|---|---|---|33| Flex Consumption (FC1) | Linux | ❌ 0 |34| Consumption (Y1) | **Windows** | ✅ 1 staging slot |35| Consumption (Y1) | Linux | ❌ 0 |36| Elastic Premium (EP1-EP3) | Windows or Linux | ✅ 20 slots |37| Dedicated (Standard+) | Windows or Linux | ✅ 5–20 slots |3839> 💡 **For Azure Functions requiring deployment slots:**40> - **Windows Consumption (Y1) supports 1 staging slot** — this is a supported platform capability.41> If you need it, use it. See the Bicep example below.42> - Recommendation for new projects: prefer **Elastic Premium (EP1+)** (no cold starts, VNet integration)43> or a **Dedicated plan (Standard+)**. Y1 cold starts can affect slot swap warm-up reliability.44> - **Linux Consumption and Flex Consumption do not support deployment slots.**4546### Windows Consumption Function App with Staging Slot (Bicep)4748```bicep49resource functionAppPlan 'Microsoft.Web/serverfarms@2022-09-01' = {50name: '${resourcePrefix}-funcplan-${uniqueHash}'51location: location52sku: { name: 'Y1', tier: 'Dynamic' }53// No 'reserved: true' — Windows Consumption54}5556resource functionApp 'Microsoft.Web/sites@2022-09-01' = {57name: '${resourcePrefix}-${serviceName}-${uniqueHash}'58location: location59kind: 'functionapp' // Windows (no 'linux' suffix)60identity: { type: 'SystemAssigned' }61properties: {62serverFarmId: functionAppPlan.id63httpsOnly: true64siteConfig: {65appSettings: [66{ name: 'WEBSITE_NODE_DEFAULT_VERSION', value: '~20' }67{ name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' }68{ name: 'FUNCTIONS_WORKER_RUNTIME', value: 'node' }69{ name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING', value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value}' }70{ name: 'WEBSITE_CONTENTSHARE', value: '${toLower(serviceName)}-prod' }71{ name: 'AzureWebJobsStorage', value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value}' }72{ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: applicationInsights.properties.ConnectionString }73]74}75}76}7778// Staging slot — only 1 staging slot supported on Consumption79resource stagingSlot 'Microsoft.Web/sites/slots@2022-09-01' = {80parent: functionApp81name: 'staging'82location: location83kind: 'functionapp'84properties: {85serverFarmId: functionAppPlan.id86siteConfig: {87appSettings: [88{ name: 'WEBSITE_NODE_DEFAULT_VERSION', value: '~20' }89{ name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' }90{ name: 'FUNCTIONS_WORKER_RUNTIME', value: 'node' }91{ name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING', value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value}' }92{ name: 'WEBSITE_CONTENTSHARE', value: '${toLower(serviceName)}-staging' } // MUST differ from production93{ name: 'AzureWebJobsStorage', value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value}' }94{ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: applicationInsights.properties.ConnectionString }95]96}97}98}99```100101> ⚠️ `WEBSITE_CONTENTSHARE` **must be unique per slot** on Windows Consumption — each slot needs its own file share.102> Use slot-sticky settings (via `slotConfigNames`) for `WEBSITE_CONTENTSHARE` and `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`103> so these values do not swap with production.104105## Deployment Flow1061071. Deploy to staging slot1082. Warm up and test staging1093. Swap staging with production1104. Rollback by swapping again if needed111112## Slot Settings113114Configure settings that should not swap:115116```bicep117resource slotConfigNames 'Microsoft.Web/sites/config@2022-09-01' = {118parent: webApp119name: 'slotConfigNames'120properties: {121appSettingNames: [122'APPLICATIONINSIGHTS_CONNECTION_STRING'123]124}125}126```127