App Config - Export to a JSON
App Config - Export to a JSON

Azure App Configuration Service – Export Key-Value Pairs to a JSON File

In previous article, we have discussed about how to import the key-value pairs from JSON file in App Configuration Service. In this article, we are going to perform the reverse operation – we are going to export the key-value pairs in the form of a JSON file.

Prerequisite

For following all steps in this article, we will need Azure Subscription. If you don’t have an Azure subscription, create a free account before you begin.

Create Azure App Configuration Service

We will need an instance of Azure App Configuration Service. You can refer this article to create one using Azure Portal. Alternatively, you can run the bicep script from this article to create one for you. Refer my GitHub repository to create the resource if you want to use the Bicep files.

Importing Key-Value Pairs

Please refer the previous article to import few key value pairs to the app configuration service. The app configuration store should have the key-value pairs as shown in the snapshot given below.

Azure Portal – Listing all the configuration settings

Azure CLI Command for Export

The command that we are going to use is az appconfig kv export. This command would need below mentioned parameters to be specified:

  • destination, the value can be appconfig, appservice or file. We need to export the key-value pairs to a file. Hence, for this demo, the parameter value should be set to file.
  • format, this value can be any one of – json, properties or yaml. As we want to export the key-value pairs to a JSON file, we will need to set this parameter to json.
  • path, this should be set to the local path where the exported file needs to be saved
  • separator, the delimiter for flattening the key-value pairs to json or yaml file. Required for exporting hierarchical structure. Separator will be ignored for property files and feature flags. Supported values: ‘.’, ‘,’, ‘;’, ‘-‘, ‘_’, ‘__’, ‘/’, ‘:’.
  • We also need to specify any one of the two parameters – name or connection-string. The name should be set to the name of app configuration store. if connection string is used, it should be set to a read-only connection string (lease priviledge principle).

The sample commands are given in the code snippet below:

Run and Verify

After we run the command given in the above code snippet, it will generate the JSON file.

Exported JSON File

I hope you find this information helpful. Let me know your thoughts.

Leave a ReplyCancel reply