You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求为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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 04:30:57