Centralized Configuration Management for the Cloud with Azure App Configuration

Centralized Configuration Management for the Cloud with Azure App Configuration

Modern cloud applications are distributed in nature. There are multiple applications running on different geographical locations and a single solution may have different services running on different platforms like App Services, Virtual Machines and Serverless functions etc. Managing application settings/configuration across these distributed instances is difficult. And when issues come up, its even more difficult to troubleshoot issues. Having a centralized location to store your application configurations help to solve these issues.

This is where Azure App Configuration comes into the picture. Azure App Configuration is a service that is still in preview, that allows you to centrally managed application settings and feature flags. It’s a feature packed solution that takes care of many aspects of configuration management. During the preview period Azure App Configuration is free and it provides the following features.

  • Fully Managed Service where you don’t have to worry about the platform where the configurations are stored, and it can be spinned up within minutes using the portal or using scripts.
  • Flexible key representation and mappings that easily allows you to store configurations in either flatly designed or hierarchically defined keys that can map to frameworks like ASP.Net Core configuration.
  • Support for Key tagging with Labels where you can add many dimensions to your configuration by tagging with labels and having multiple values for a single key.
  • Point in time snapshots that can be replayed incase you want to revert changes or compare configuration on two different points in time.
  • Ability to compare configurations on labels, date and time etc.
  • Encrypted configurations at rest and on transit for secure configuration storage.
  • Support for using Managed Identities to eliminate the use of connection strings to access Azure App Configuration
  • A dedicated UI for feature flag management and the ability to integrate with many popular frameworks.

So, you can see Azure App Configuration is a secure place to store your application configuration centrally. But what about Azure Key Vault?

Azure Key Vault vs Azure App Configuration

Even though Azure App Configuration is a secure service to store application configurations, it’s not a replacement for Azure Key Vault. You can certainly store your secrets in Azure App Configuration, but Azure Key Vault is still the best place for secrets and keys with more features and granular access to your secrets and keys with Access Policies etc. Think of Azure App Configuration as a service that complements Azure Key Vault, not a replacement for Azure Key Vault.

Using Azure App Configuration with ASP.Net Core Application

It is easy to use Azure App Configuration with your ASP.Net Core applications by using the provider SDK which is installed using NuGet. I have prepared a simple ASP.Net Core MVC application that shows a Title and a Description on the home page that takes the title and description from the appsettings.json. The code sample is available on GitHub. This sample uses a HomeViewModel to send the Title and Description to the Home/Index view.

To enable the use of Azure App Configuration you need to install Microsoft.Azure.AppConfiguration.AspNetCore NuGet package. You need to enable Include Prerelease checkbox to see the NuGet package in the feed since the package is still in preview release. After the package is installed, you need to modify your Web Host Builder logic to add the code needed. We can use the ConfigureAppConfiguration() method to plug in Azure App Configuration code into ASP.Net Core Application configuration.

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    .ConfigureAppConfiguration((context, config) =>
      var settings = config.Build();

      // Connect to Azure App Configuration using the Connection String.

You need to get the Connection String to pass in to the AddAzureAppConfiguration() method. This is available via the Azure Portal. See the screenshot below.

image 1

Azure App Configuration Connection Strings

The connection string is stored in the appsettings.json file and loaded via ASP.Net Core configuration using the IConfigurationRoot by using the ConnectionStrings:AppConfiguration key.

The app settings are also put into the Azure App Configuration Instances, Configuration Explorer view. Here you can see I have added the AppSettings:HomePage:Description and AppSettings:HomePage:Title configurations to the instance. These keys represent the hierarchical keys that I have in my appsettings.json file. You can add configuration key-value pairs using Create button.

image 2

Azure App Configuration - Configuration Explorer

This is all we need to configure Azure App Configuration with ASP.Net Core MVC application. When you run the application, you can see that the application is pulling configuration values from Azure App Configuration.

image 3

Application Running


Decoupling your application configuration from your application code is a best practice when it comes to developing modern software solutions. And Azure App Configuration helps you centralize your application configuration and managed, troubleshoot them easily. Hope you got a really basic understanding about Azure App Configuration, in the upcoming articles we’ll dive deep in to Azure App Configurations capabilities and implementation.

The source code for this article can be found in the Azure App Configuration Basic Example GitHub Repo.

You Might Also Like