azure-functions - 将设置粘贴到暂存槽

标签 azure-functions azure-deployment azure-deployment-slots

我有以下二头肌文件,它添加了带有配置设置的部署槽:

var appSettings = [
  {
    name: 'WEBSITE_RUN_FROM_PACKAGE'
    value: 1    
  }
  {
    name: 'WEBSITE_ENABLE_SYNC_UPDATE_SITE'
    value: 1    
  }
]

var stagingSettings = [ 
  {
    name: 'AzureWebJobs.StarterFunction.Disabled'
    value: 1
  }
]

var productionSettings = [ 
  {
    name: 'AzureWebJobs.StarterFunction.Disabled'
    value: 0
  }
]

module functionAppTemplate 'functionApp.bicep' = {
  name: 'functionAppTemplate'
  params: {
    name: '${functionAppName}'
    kind: functionAppKind
    location: location
    servicePlanName: servicePlanName
    secretSettings: union(appSettings, productionSettings)
  }
  dependsOn: [
    servicePlanTemplate
  ]
}

module functionAppSlotTemplate 'functionAppSlot.bicep' = {
  name: 'functionAppSlotTemplate'
  params: {
    name: '${functionAppName}/staging'
    kind: functionAppKind
    location: location
    servicePlanName: servicePlanName
    secretSettings: union(appSettings, stagingSettings)
  }
  dependsOn: [
    functionAppTemplate
  ]
}

functionApp.bicep:

resource functionApp 'Microsoft.Web/sites@2018-02-01' = {
  name: name
  location: location
  kind: kind
  properties: {
    serverFarmId: resourceId('Microsoft.Web/serverfarms', servicePlanName)
    clientAffinityEnabled: false
    httpsOnly: true
    siteConfig: {
      use32BitWorkerProcess : false
      appSettings: secretSettings
    }
  }
  identity: {
    type: 'SystemAssigned'
  }
}


resource functionAppSlotConfig 'Microsoft.Web/sites/config@2021-03-01' = {
  name: 'slotConfigNames'
  parent: functionApp
  properties: {
    appSettingNames: [
      'AzureWebJobs.StarterFunction.Disabled'
    ]
  }
}

functionAppSlot.bicep

resource functionAppSlot 'Microsoft.Web/sites/slots@2018-11-01' = {
  name: name
  kind: kind
  location: location
  properties: {
    clientAffinityEnabled: true
    enabled: true
    httpsOnly: true
    serverFarmId: resourceId('Microsoft.Web/serverfarms', servicePlanName)
    siteConfig: {
      use32BitWorkerProcess : false
      appSettings: secretSettings
    }
  }
  identity: {
    type: 'SystemAssigned'
  }
}

我希望此设置“AzureWebJobs.StarterFunction.Disabled”仅用于暂存槽(不适用于生产槽),并将该设置粘贴到暂存槽。我将如何更新此代码?

最佳答案

不可能使用二头肌将设置粘贴到暂存槽。您需要将设置粘贴到您的生产插槽中。

需要使用'Microsoft.Web/sites/config@2022-03-01'

resource appServiceStickySetting 'Microsoft.Web/sites/config@2022-03-01' = {
  name: 'slotConfigNames'
  parent: appService // <-- This needs to be a /sites resource (reference error below)
  properties: {
    appSettingNames: [
      "Setting Name Here"
    ]
  }
}

Error You Get If You Enter For A Slot Setting

关于azure-functions - 将设置粘贴到暂存槽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72147208/

相关文章:

azure - 如何在 Azure Function 中写入 Azure 事件网格主题

azure - 不支持关键字 : 'authentication' error for azure integrated connection

Azure函数部署错误: 503 Temporarily Unavailable

c# - 自动化事件网格时出现 ResourceDeploymentFailure 错误

Azure 启动脚本未执行

entity-framework - Azure Web 作业运行一次

c# - 创建 Web 作业计划时出错

azure - Azure 静态 Web 应用中的部署槽如何工作

Azure 部署槽 - 交换和保留连接字符串