请求为Azure App Service Bicep模板添加staging部署槽(克隆父级设置)
为Azure App Service添加Staging部署槽的Bicep模板修改方案
要添加名为staging的部署槽并从父应用克隆配置,只需在现有模板中新增一个Microsoft.Web/sites/slots资源,修改后的完整模板如下:
resource appServicePlan 'Microsoft.Web/serverfarms@2020-06-01' = { name: appServicePlanName location: location properties: { reserved: true } sku: { name: sku } kind: 'linux' } resource appService 'Microsoft.Web/sites@2020-06-01' = { name: webAppName location: location properties: { serverFarmId: appServicePlan.id siteConfig: { linuxFxVersion: linuxFxVersion } } } // 添加staging部署槽,从父应用克隆配置 resource appServiceStagingSlot 'Microsoft.Web/sites/slots@2020-06-01' = { parent: appService name: 'staging' location: location properties: { serverFarmId: appServicePlan.id siteConfig: { cloneSourceControl: true cloneCustomHostNames: false cloneAppSettings: true linuxFxVersion: appService.properties.siteConfig.linuxFxVersion } } }
关键配置说明
parent: appService:明确该部署槽归属于已定义的主App Service资源cloneSourceControl: true:克隆父应用的源代码管理配置cloneAppSettings: true:克隆父应用的应用设置cloneCustomHostNames: false:不克隆自定义域名( staging 槽通常无需绑定生产域名)- 复用
appServicePlan.id:确保部署槽与主应用使用同一服务计划,避免额外资源开销
内容的提问来源于stack exchange,提问作者Krish
相关产品推荐
相关产品推荐

