Coder Perfect

When merging appsettings, there is a circular dependency on the arm template (bicep) (list function)


I’m trying to use a bicep file to update the AppSettings of an App Service.

When using my bicep template, I’ll do the following:

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

When I publish the bicep file, I get a circular dependency error:

"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 for usage details.'."

Is there a way to accomplish this without seeing the dependencies error?

Asked by Peter Wyss

Solution #1

Make use of modules. Modules in the Bicep framework are essentially nested deployments. Extract the current values from the top-level file (i.e. main) and give them as an object argument to the submodule (appsettings), then merge and update. The key is to put the update in a distinct module from the one that reads the current value.

Answered by Miq

Post is based on