简体   繁体   中英

How to get Azure App Configuration feature flag value list in bicep template

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)

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.

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