0

I would like to get list of already created feature flags from Azure App Configuration in bicep template. I want to pass it to separate bicep file that will use union function on existing and new feature flags to not override already existing ones.

Simillar thing I'm already using for Web App and list() function get existing app settings:

module appConfig './webappsettings.bicep' = {
  name: '${deployment().name}-appSettings'
  params: {
    webAppName: webapp.name
    currentAppSettings: list('${webapp.id}/config/appsettings', '2021-03-01').properties
    appSettings: allSettings
  }
}

How can I achieve something similar for Azure App Configuration to get key values of feature flags?

I tried with below solution but I only got key values of App Configuration

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

module configStoreKeyValues 'inner.bicep' = {
  name: 'config-store'
  params: {
    existingKeyValues: configurationStore.listKeys().value
    keyValues: keyValues
    contentType: contentType
  }
}

using same list() function or listKeys()

list('${configurationStore.id}/keyValues','2021-10-01-preview').properties

I'm getting an error:

Status Message: The resource namespace 'subscriptions' is invalid. (Code:InvalidResourceNamespace)

  • Each feature flag has its own resource definition so you don't need to merge them. if you create a new feature flag it wont delete previously created featureflags. it's quite different from appsettings. see https://stackoverflow.com/q/72000069/4167200 – Thomas Jul 26 '22 at 19:26
  • @Thomas thank you for the answer, then one more question how to get individual resource from app configuration service in bicep? `resource configurationStoreKey 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' existing = { parent: configurationStore name: '.appconfig.featureflag~2F${keyValues[0].name}' }` that unfortunately doesnt work for me – Łukasz Krupa Jul 27 '22 at 08:40
  • what is the error youre getting ? – Thomas Jul 27 '22 at 09:22
  • @Thomas I'm getting an error: `Status Message: The resource namespace 'subscriptions' is invalid. (Code:InvalidResourceNamespace)` – Łukasz Krupa Jul 27 '22 at 09:35
  • it is working for me tho. what is the scope for your deployment ? – Thomas Jul 27 '22 at 09:50
  • @Thomas I'm using resource group of my app configuration service, could you share your working code snippet? – Łukasz Krupa Jul 27 '22 at 10:37

1 Answers1

0

The "List" operation of key-values is not supported by the control-plane REST API in App Configuration. The listKeys API you used above returns the "Access keys", not the key-value configuration data you are looking for. You can create/update/read individual key-value, feature flag, Key Vault reference as KeyValues resource using Bicep. Feature flag is a special key-value with certain key prefix and content type. Below is an example of feature flag using the ARM template, but it should give you an idea of how to do the same in Bicep.

https://azure.microsoft.com/resources/templates/app-configuration-store-ff/

Note that the "List" operation of key-values is supported in the data-plane REST API of App Configuration. Besides the REST API, it's also accessible via Azure CLI, Azure portal, and App Configuration SDKs programmatically.

Zhenlan Wang
  • 1,213
  • 8
  • 10
  • Thank you for pointing that I should consider it as an individual key-value resource, however is there a way to check it in loop if it exist in App Configuration service and insert it in case when feature flag is not present? Currently I'm not able to take any value but just insert/update new ones I want to avoid problem with overriding values in feature manager – Łukasz Krupa Jul 27 '22 at 07:56