asd*_*psd 14 azure azure-resource-manager azure-web-app-service azure-bicep
主二头肌
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: webSiteName
location: location
properties: {
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: linuxFxVersion
appSettings: [
{
name: 'ContainerName'
value: 'FancyContainer'
}
{
name: 'FancyUrl'
value: 'fancy.api.com'
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
基础结构发布过程成功运行,并且应用程序设置设置正确,之后我运行节点应用程序构建和发布,其中 Azure DevOps 发布管道将一些与应用程序相关的配置添加到应用程序设置。(例如 API 密钥、API URL),一切都运行良好。
但是,如果我必须重新发布基础架构,例如,我使用存储帐户扩展我的环境,则应用程序发布设置的应用程序设置将丢失。
是否有解决方法可以保留 Bicep 模板中未定义的应用程序设置?
Tho*_*mas 27
来自本文:将应用程序设置与 Bicep 合并。
appSettings在其中siteConfig。appsettings.bicep文件:
param webAppName string
param appSettings object
param currentAppSettings object
resource webApp 'Microsoft.Web/sites@2022-03-01' existing = {
name: webAppName
}
resource siteconfig 'Microsoft.Web/sites/config@2022-03-01' = {
parent: webApp
name: 'appsettings'
properties: union(currentAppSettings, appSettings)
}
Run Code Online (Sandbox Code Playgroud)
主要二头肌:
param webAppName string
...
// Create the webapp without appsettings
resource webApp 'Microsoft.Web/sites@2022-03-01' = {
name: webAppName
...
properties:{
...
siteConfig: {
// Dont include the appSettings
}
}
}
// Create-Update the webapp app settings.
module appSettings 'appsettings.bicep' = {
name: '${webAppName}-appsettings'
params: {
webAppName: webApp.name
// Get the current appsettings
currentAppSettings: list(resourceId('Microsoft.Web/sites/config', webApp.name, 'appsettings'), '2022-03-01').properties
appSettings: {
Foo: 'Bar'
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7633 次 |
| 最近记录: |