In previous article, we have created an Azure App Configuration Service instance. We also have show the menu option from where the app settings (key-value pairs) can be added.
In this article, we are going to discuss more about how to add key value pairs in that instance.
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. You will also need to create a new App Configuration store.
You can refer the detailed steps from the previous article. Once the resource is created, you can follow the next steps to create the key-value pair.
Azure Portal – Option to add key value pair
Once the Azure App Configuration Service instance is created, the next step is to add the configuration settings here. We can select Operations -> Configuration explorer -> Create -> Key-value option to add the key-value pairs, which would be used by the applications.
Azure App Configuration Service stores the application settings in the form of key-value pairs. This is because key-value pairs is the simplest way in which the application settings can be represented.
There are four different input types. We are going to discuss about these inputs.
This input is mandatory. It is the identifier for the setting and it can be used to look for the corresponding value. Because these are used for querying the settings, it is generally best in our interest to provide a meaningful name to this identifier.
It is a common practice to organize keys into hierarchical namespaces. The namespace tokens can be delimited by colon character
: or slash character
/. But we can use any delimiter as we wish. From the perspective of Azure App Configuration Service, it does not matter. The service itself does not parse keys and does not enforce any rules, it just treats the keys as they are. Hence, we can use any convention that is suited for our application.
In my opinion, the namespace name can contain application name, environment name and setting name. If the application is being deployed in multiple regions, then it may be good idea to include the region name as well in the setting name. This hierarchy is useful especially when some features are enabled in one region while the same features are not enabled in the other regions.
The keys are basically case-sensitive. So the key “Setting_Name” and “setting_Name” is not same.
This input is basically for the value of identifier. We can use unicode characters in the value.
This is one of the input on the panel where the labels can be specified. It is an optional attribute. When we want to have multiple key-value pairs with same key, then labels can be used to differentiate them. Label provides a convenient way to create variants of a key. They can be used to query the key.
In the key namespaces discussed in the section above, the the environment name can be used as label instead of using as a token in the namespace as shown in the code snippet given below.
Key = AppName:DbEndpoint & Label = Test
Key = AppName:DbEndpoint & Label = Staging
Key = AppName:DbEndpoint & Label = Production
This is another optional input, which can be used to specify the type of the value. This type can be then used by the consumers to property parse and process the value.
There is no specific format for specifying content types. App Configuration uses Media Types (also known as MIME types) for built-in data types such as feature flags, Key Vault references, and JSON key-values.
I hope this article provides all the basic information about how to create key-value pairs in Azure App Configuration Service. Let me know your thoughts.