How to Integrate Azure App Configuration in ASP.NET Core for Centralized Settings


In an ASP .NET Core application, configuration values are often stored in appsettings.json
.
For different environments, we typically create separate files such as appsettings.Development.json
, appsettings.Staging.json
, and appsettings.Production.json
.
While this approach works, it comes with several drawbacks—especially in production:
Deployment Complexity.
Even small configuration changes may require a full CI/CD pipeline run or manual updates in each environment on your cloud server. This slows down delivery and increases operational overhead.
Difficult to Maintain.
If you have multiple environments (e.g., Development, Staging, and Production), keeping all configuration files synchronized can be error-prone. Missing or outdated values in one environment can lead to bugs or inconsistencies.
Limited Access Control.
appsettings.json
is accessible to anyone with file system access. Fine-grained access control—such as granting read-only permissions to specific keys—is not straightforward.
This is why you need central configuration.
A centralized configuration system solves these problems by providing:
One source of truth for configuration values.
Instant updates without requiring application redeployments.
Better security and access control for sensitive values.
Azure App Configuration
Azure App Configuration is a fully managed service that lets you store, manage, and distribute application settings from a single location.
Rather than storing configuration values in local files and including them in your codebase, you should keep them in a centralized store and retrieve them at runtime.
Key benefits:
Instant configuration updates without redeploying your app
Consistency across multiple environments and applications
Dynamic settings support, including feature flags
Let’s get started.
Setting Up Azure App Configuration.
Create the service.
In the Azure Portal, search for App Configuration in the top search bar.
Click Create and provide the required details (subscription, resource group, region, and name). Once done, click Review + Create, then Create.Add configuration values.
After the resource is created, open it and navigate to Configuration Explorer from the left-hand menu.
Click + Create to add a new key-value pair.Define your settings.
You can add keys in the same way you would structure them inappsettings.json
. For example:AppSettings:AppName
→"My Web App"
:
as a separator), allowing you to mirror your application’s configuration structure.The example below shows what it looks like in the Azure configuration.
Note: You can categorize your key using a label.
It’s similar to this structure in your appsettings.json
:
{
"AppSettings": {
"AppName": "MyApp",
"Developer": "Kristiadhy"
}
}
Now, let's look at how you can read it from your app.
Connecting your ASP NET Core app to Azure App Configuration.
Here’s how you can connect your app to Azure App Configuration.
Install the required NuGet packages
From your project directory, run:
dotnet add package Microsoft.Azure.AppConfiguration.AspNetCore
Retrieve the connection string from Azure
In the Azure Portal, navigate to your App Configuration resource and:
Go to Access Settings in the left-hand menu.
Copy the Primary Connection String.
Note: You'll have Read-Write keys or Read-Only keys. Please select accordingly.
Note: To use a user secret in Visual Studio, right-click your project and select Manage User Secret. Then, enter the value as shown in the example below.
Update Program.cs
to use Azure App Configuration
Modify your Program.cs
to load configuration from Azure:
using Azure.Identity;
var builder = WebApplication.CreateBuilder(args);
// Connect to Azure App Configuration
builder.Configuration.AddAzureAppConfiguration(options =>
{
options.Connect(builder.Configuration["AzureAppConfiguration:ConnectionString"]);
});
builder.Services.AddAzureAppConfiguration();
var app = builder.Build();
app.UseAzureAppConfiguration();
app.MapControllers();
app.Run();
Using the configuration in your code.
public class AppConfigController : ControllerBase
{
private readonly IConfiguration _configuration;
public AppConfigController(IConfiguration configuration)
{
_configuration = configuration;
}
[HttpGet("Configuration")]
public IActionResult GetAppConfigValueFromConfiguration()
{
var appSettings = new AppSettings
{
AppName = _configuration["AppSettings:AppName"]!,
Developer = _configuration["AppSettings:Developer"]!
};
return Ok(appSettings);
}
}
The example above is also not recommended 🚫; it’s better to use the Option Pattern instead of injecting the configuration directly into your controller. In the free repository below, I have provided a more robust approach ✅:
Using an extension method that makes your
program.cs
cleaner.Different refresh settings with explanations to help you understand the refresh with multiple approaches.
Using the Option Pattern for a more effective approach.
Grab this for repository free: https://github.com/kristiadhy/AzureAppConfigAndKeyVaultIntegration
Note: If you find this helpful, please like the repo.
Conclusion
By using Azure App Configuration, you centralize configuration management, enabling instant updates across environments without redeployments.
This combination delivers:
Centralized management for all application settings.
Consistent configuration across multiple apps and environments.
Faster, safer updates without downtime.
In the next article, I'll explain how to integrate the Azure App Configuration and Key Vault.
Subscribe to my newsletter
Read articles from Kristiadhy directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Kristiadhy
Kristiadhy
Experienced Full Stack .NET developer with a proven track record of designing and implementing robust business applications. Proficient in using ASP.NET Core Web API, Blazor, and WinForms to deliver high-quality, efficient code and scalable solutions. Strong focus on implementing industry best practices for cleaner and scalable outcomes.