Pular para o conteúdo

Get started with the Azure App Configuration integrations

Este conteúdo não está disponível em sua língua ainda.

Azure App Configuration logo

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.

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:

Aspire CLI — Adicionar pacote Aspire.Hosting.Azure.AppConfiguration
aspire add azure-appconfiguration

A Aspire CLI é interativa; escolha o resultado adequado quando solicitado:

Aspire CLI — Exemplo de saída
Select an integration to add:
> azure-appconfiguration (Aspire.Hosting.Azure.AppConfiguration)
> Other results listed as selectable options...

Next, in the AppHost project, create an Azure App Configuration resource and pass it to the consuming client projects:

C# — AppHost.cs
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();

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:

.NET CLI — Add Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration package
dotnet add package Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration

In the Program.cs file of your client-consuming project, call the AddAzureAppConfiguration extension method to register the required services:

C# — Program.cs
builder.AddAzureAppConfiguration(connectionName: "config");

You can then retrieve the IConfiguration instance using dependency injection:

C# — ExampleService.cs
public class ExampleService(IConfiguration configuration)
{
private readonly string _someValue = configuration["SomeKey"];
}