Quickstart: Create an Azure App Configuration store using Bicep

This quickstart describes how you can use Bicep to:

  • Deploy an App Configuration store.
  • Create key-values in an App Configuration store.
  • Read key-values in an App Configuration store.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

Prerequisites

If you don't have an Azure subscription, create a trial subscription before you begin.

Authorization

Managing an Azure App Configuration resource with Bicep file requires an Azure Resource Manager role, such as contributor or owner. Accessing Azure App Configuration data (key-values, snapshots) requires an Azure Resource Manager role and an additional Azure App Configuration data plane role when the configuration store's ARM authentication mode is set to pass-through ARM authentication mode.

Important

Configuring ARM authentication mode requires App Configuration control plane API version 2023-08-01-preview or later.

Review the Bicep file

The Bicep file used in this quickstart is from Azure Quickstart Templates.

Note

Bicep files use the same underlying engine as ARM templates. All of the tips, notes, and important information found in the ARM template quickstart apply here. It's recommended to reference this information when working with Bicep files.

@description('Specifies the name of the App Configuration store.')
param configStoreName string

@description('Specifies the Azure location where the app configuration store should be created.')
param location string = resourceGroup().location

@description('Specifies the names of the key-value resources. The name is a combination of key and label with $ as delimiter. The label is optional.')
param keyValueNames array = [
  'myKey'
  'myKey$myLabel'
]

@description('Specifies the values of the key-value resources. It\'s optional')
param keyValueValues array = [
  'Key-value without label'
  'Key-value with label'
]

@description('Specifies the content type of the key-value resources. For feature flag, the value should be application/vnd.microsoft.appconfig.ff+json;charset=utf-8. For Key Value reference, the value should be application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8. Otherwise, it\'s optional.')
param contentType string = 'the-content-type'

@description('Adds tags for the key-value resources. It\'s optional')
param tags object = {
  tag1: 'tag-value-1'
  tag2: 'tag-value-2'
}

resource configStore 'Microsoft.AppConfiguration/configurationStores@2021-10-01-preview' = {
  name: configStoreName
  location: location
  sku: {
    name: 'standard'
  }
}

resource configStoreKeyValue 'Microsoft.AppConfiguration/configurationStores/keyValues@2021-10-01-preview' = [for (item, i) in keyValueNames: {
  parent: configStore
  name: item
  properties: {
    value: keyValueValues[i]
    contentType: contentType
    tags: tags
  }
}]

output reference_key_value_value string = configStoreKeyValue[0].properties.value
output reference_key_value_object object = configStoreKeyValue[1]

Two Azure resources are defined in the Bicep file:

With this Bicep file, we create one key with two different values, one of which has a unique label.

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location chinaeast
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters configStoreName=<store-name>
    

    Note

    Replace <store-name> with the name of the App Configuration store.

    When the deployment finishes, you should see a message indicating the deployment succeeded.

Review deployed resources

Use Azure CLI or Azure PowerShell to list the deployed resources in the resource group.

az resource list --resource-group exampleRG

You can also use the Azure portal to list the resources:

  1. Sign in to the Azure portal.
  2. In the search box, enter App Configuration, then select App Configuration from the list.
  3. Select the newly created App Configuration resource.
  4. Under Operations, select Configuration explorer.
  5. Verify that two key-values exist.

Clean up resources

When no longer needed, use Azure CLI or Azure PowerShell to delete the resource group and its resources.

az group delete --name exampleRG

You can also use the Azure portal to delete the resource group:

  1. Navigate to your resource group.
  2. Select Delete resource group.
  3. A tab will appear. Enter the resource group name and select Delete.

Next steps

To learn about adding feature flag and Key Vault reference to an App Configuration store, check out the ARM template examples.