带有模块的 azure bicep 模板执行 web 插槽配置 appsettings 的联合
azure bicep template with module doing a union of web slot config appsettings
我正在尝试获取我当前 sites/slot 应用程序配置的列表,然后将其与联合组合,这样我就不会覆盖当前部署的配置。我可以使用站点配置来执行此操作,但不能使用部署槽。
这是我的 工作 网站的示例
在 main.bicep
resource sites_web_name 'Microsoft.Web/sites@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_appsettings_config './appsettings.bicep' = {
name: 'webAppSettings'
params: {
//this gets a list of the current app settings for the web site resource
currentAppSettings: list('${sites_web_name.id}/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_name.name}/appsettings'
}
}
appsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteConfig 'Microsoft.Web/sites/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
以上是部署当前应用设置,如果模板中未指定新设置,则 deleting/overwriting 不会部署它们。
现在尝试获取问题sites/slot
main.bicep
resource sites_web_slots_name 'Microsoft.Web/sites/slots@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_staging_appsettings_config './slotappsettings.bicep' = {
name: 'webStagingAppSettings'
params: {
//this gets a list of the current app settings for the web slot resource
currentAppSettings: list('${sites_web_slots_name.id}/slots/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_slots_name.name}/appsettings'
}
}
甚至做了一个单独的模块,slotappsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteSlotConfig 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
我得到的插槽故障错误根本没有帮助:
ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"至少一个资源部署操作失败。请列出部署操作以获取详细信息。请有关使用详情,请参阅 https://aka.ms/DeployOperations。","details":[{"code":"NotFound","message":"{\r\n "error": {\r\n "code" : "InvalidResourceNamespace",\r\n "message": "资源命名空间 'subscriptions' 无效。"\r\n }\r\n}"}]}}
我在 Azure 门户中也没有收到任何部署失败消息。
这是我使用的 api 版本的文档:
sites/config/appsettings:
resource symbolicname 'Microsoft.Web/sites/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
sites/slots/config/appsettings:
sites/slots/config-appsettings
resource symbolicname 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
调用插槽设置的 list
函数时出现拼写错误:
你有 /slots/config/appsettings
但它应该只是 /config/appsettings
因为 /slots
段已经包含在插槽的资源 ID 中 (sites_web_slots_name.id
)
我正在尝试获取我当前 sites/slot 应用程序配置的列表,然后将其与联合组合,这样我就不会覆盖当前部署的配置。我可以使用站点配置来执行此操作,但不能使用部署槽。
这是我的 工作 网站的示例 在 main.bicep
resource sites_web_name 'Microsoft.Web/sites@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_appsettings_config './appsettings.bicep' = {
name: 'webAppSettings'
params: {
//this gets a list of the current app settings for the web site resource
currentAppSettings: list('${sites_web_name.id}/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_name.name}/appsettings'
}
}
appsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteConfig 'Microsoft.Web/sites/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
以上是部署当前应用设置,如果模板中未指定新设置,则 deleting/overwriting 不会部署它们。
现在尝试获取问题sites/slot
main.bicep
resource sites_web_slots_name 'Microsoft.Web/sites/slots@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_staging_appsettings_config './slotappsettings.bicep' = {
name: 'webStagingAppSettings'
params: {
//this gets a list of the current app settings for the web slot resource
currentAppSettings: list('${sites_web_slots_name.id}/slots/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_slots_name.name}/appsettings'
}
}
甚至做了一个单独的模块,slotappsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteSlotConfig 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
我得到的插槽故障错误根本没有帮助:
ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"至少一个资源部署操作失败。请列出部署操作以获取详细信息。请有关使用详情,请参阅 https://aka.ms/DeployOperations。","details":[{"code":"NotFound","message":"{\r\n "error": {\r\n "code" : "InvalidResourceNamespace",\r\n "message": "资源命名空间 'subscriptions' 无效。"\r\n }\r\n}"}]}}
我在 Azure 门户中也没有收到任何部署失败消息。 这是我使用的 api 版本的文档:
sites/config/appsettings:
resource symbolicname 'Microsoft.Web/sites/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
sites/slots/config/appsettings:
sites/slots/config-appsettings
resource symbolicname 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
调用插槽设置的 list
函数时出现拼写错误:
你有 /slots/config/appsettings
但它应该只是 /config/appsettings
因为 /slots
段已经包含在插槽的资源 ID 中 (sites_web_slots_name.id
)