简体   繁体   中英

Arm Template (Bicep): Circular Dependency when merging appsettings (list function)

I'm trying to update the AppSettings of an App Service through a bicep file.

When doing this in my bicep template:

var currentAppSettings = list('Microsoft.Web/sites/appServiceName/config/appsettings', '2018-11-01')

var newAppSettings = {
  test: 'testValue'
}

var mergedAppSettings = union(currentAppSettings, newAppSettings)

resource appServiceConfig 'Microsoft.Web/sites/config@2018-11-01' = {
  name: 'appServiceName/appSettings'
  properties: mergedAppSettings
}

...I get a circular dependency error when deploying the bicep file:

"Deployment template validation failed: 'Circular dependency detected on resource: '/subscriptions/293d7347-b26f-4413-9986-d61717aaff26/resourceGroups/WSAPlayground/providers/Microsoft.Web/sites/playground-fitxp-backend-euw-wa/config/appSettings'. Please see https://aka.ms/arm-template/#resources for usage details.'."

Is there a way to do this without getting the dependency error?

try using modules. Bicep modules are essentially nested deployments. in the top level file (ie main) extract the current values and pass them to the submodule (appsettings) as parameter of type object and then execute merge and update. clue is to deploy the update in a different module than reading current value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM