Get started with the Azure App Configuration integrations
Azure App Configuration provides a service to centrally manage application settings and feature flags. Modern programs, especially programs running in a cloud, generally have many components that are distributed in nature. Spreading configuration settings across these components can lead to hard-to-troubleshoot errors during an application deployment. The Aspire Azure App Configuration integration enables you to connect to existing App Configuration instances or create new instances all from your AppHost.
In this introduction, you'll see how to install and use the Aspire Azure App Configuration integrations in a simple configuration. If you already have this knowledge, see Azure App Configuration Hosting integration for full reference details.
Note
To follow this guide, you must have created an Aspire solution to work with. To learn how to do that, see Build your first Aspire app.
Set up hosting integration
To begin, install the Aspire Azure App Configuration Hosting integration in your Aspire AppHost project. This integration allows you to create and manage Azure App Configuration resources from your Aspire hosting projects:
dotnet add package Aspire.Hosting.Azure.AppConfigurationNext, in the AppHost project, create an Azure App Configuration resource and pass it to the consuming client projects:
var builder = DistributedApplication.CreateBuilder(args);
var appConfig = builder.AddAzureAppConfiguration("config");
builder.AddProject<Projects.WebApplication>("web")
.WithReference(appConfig);
// After adding all resources, run the app...
builder.Build().Run();
Caution
When you call AddAzureAppConfiguration, it implicitly calls
AddAzureProvisioning—which adds support for generating Azure resources
dynamically during app startup. The app must configure the appropriate
subscription and location. For more information, see Local provisioning:
Configuration.
Set up client integration
To get started with the Aspire Azure App Configuration client integration, install the 📦 Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration NuGet package in the client-consuming project:
dotnet add package Aspire.Microsoft.Extensions.Configuration.AzureAppConfigurationIn the Program.cs file of your client-consuming project, call the AddAzureAppConfiguration extension method to register the required services:
builder.AddAzureAppConfiguration(connectionName: "config");
Tip
The connectionName parameter must match the name used when adding the App Configuration resource in the AppHost project.
You can then retrieve the IConfiguration instance using dependency injection:
public class ExampleService(IConfiguration configuration)
{
private readonly string _someValue = configuration["SomeKey"];
}