Home > database >  Adding Azure App Configuration Store values using Bicep
Adding Azure App Configuration Store values using Bicep

Time:03-14

I'm trying to add values to an Azure App Configuration Store using Bicep. I have an issue where I add a label to a keyValue.

This is my module:

@description('Configuration Store Name')
param configurationStoreName string

@description('key prefix')
param prefix string

@description('key name')
param keyName string

@description('value')
param value string

@description('content type')
param contentType string = 'string'

@description('Deployment Environment')
param deploymentEnvironment string = 'dev'

resource configurationStore 'Microsoft.AppConfiguration/configurationStores@2021-10-01-    preview' existing = {
name: configurationStoreName
}

resource configurationStoreValue     'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = {
  name: '${prefix}:${keyName}'
  parent: configurationStore
  properties: {
    contentType: contentType
    value: value
    tags: {
      environment: deploymentEnvironment
    }
  }
}

There doesn't seem to be any way to add a label, which I want to do to enable filtering.

It can be done when creating KeyValues using the Azure Portal, therefore it should be possible using Bicep.

Am I missing something, or is this missing functionality from Bicep?

CodePudding user response:

From this issue on github: Adding keys using ARM templates.

Please be noted that for simplicity, the sample doesn't add label for the feature flag. Below is an example of adding label myLabel.
"name": "[concat('.appconfig.featureflag~2F', parameters('featureFlagName'), '$myLabel')]"

I tried this approach and it works:

@description('Configuration Store Name')
param configurationStoreName string

@description('key prefix')
param prefix string

@description('key name')
param keyName string

@description('value')
param value string

@description('label')
param label string

@description('content type')
param contentType string = 'string'

@description('Deployment Environment')
param deploymentEnvironment string = 'dev'

resource configurationStore 'Microsoft.AppConfiguration/configurationStores@2021-10-01-preview' existing = {
  name: configurationStoreName
}

var keyValueName = empty(label) ? '${prefix}:${keyName}' : '${prefix}:${keyName}$${label}'

resource configurationStoreValue 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = {
  name: keyValueName
  parent: configurationStore
  properties: {
    contentType: contentType
    value: value
    tags: {
      environment: deploymentEnvironment
    }
  }
}

  • Related