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.
Set up hosting integration
Section titled “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:
aspire add azure-appconfigurationAspire CLI는 대화형입니다. 프롬프트 시 알맞은 검색 결과 선택:
Select an integration to add:
> azure-appconfiguration (Aspire.Hosting.Azure.AppConfiguration)> Other results listed as selectable options...#:package Aspire.Hosting.Azure.AppConfiguration@*<PackageReference Include="Aspire.Hosting.Azure.AppConfiguration" Version="*" />Next, 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();Set up client integration
Section titled “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.AzureAppConfiguration#:package Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration@*<PackageReference Include="Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="*" />In the Program.cs file of your client-consuming project, call the AddAzureAppConfiguration extension method to register the required services:
builder.AddAzureAppConfiguration(connectionName: "config");You can then retrieve the IConfiguration instance using dependency injection:
public class ExampleService(IConfiguration configuration){ private readonly string _someValue = configuration["SomeKey"];}