Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bicep: avoid redundancy in appSettings

I define multiple app services in a bicep script. For each one i use config resource to define the configuration.

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
  parent: appService1
  name: 'appsettings'
  properties: {
    CONFIG1: value1
    CONFIG2: value2
    COMMON_CONFIG1: commom1
    COMMON_CONFIG2: commom2
  }
}

resource appSettings2 'Microsoft.Web/sites/config@2022-03-01' = {
  parent: appService2
  name: 'appsettings'
  properties: {
    CONFIG3: value3
    CONFIG4: value4
    COMMON_CONFIG1: commom1
    COMMON_CONFIG2: commom2
  }
}

There are a lot of common settings across the app services. Is there a way that im able to define the common settings only once and inject them to every config, so that i dont have to define the same settings in every app service?
Somehow like this:

var commomSettings: {
    COMMON_CONFIG1: commom1
    COMMON_CONFIG2: commom2
}

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
  parent: appService1
  name: 'appsettings'
  properties: {
    CONFIG1: value1
    CONFIG2: value2
    ...commonSettings //somehow inject commonSettings
  }
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes you are on the right track, you can use the union function to merge the objects:

var commomSettings = {
  COMMON_CONFIG1: commom1
  COMMON_CONFIG2: commom2
}

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
  parent: appService1
  name: 'appsettings'
  properties: union(commomSettings, {
      CONFIG1: value1
      CONFIG2: value2
    }
  )
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading