Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration
9.3.0-preview.1.25265.20
Prefix Reserved
See the version list below for details.
dotnet add package Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration --version 9.3.0-preview.1.25265.20
NuGet\Install-Package Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration -Version 9.3.0-preview.1.25265.20
<PackageReference Include="Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="9.3.0-preview.1.25265.20" />
<PackageVersion Include="Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="9.3.0-preview.1.25265.20" />
<PackageReference Include="Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration" />
paket add Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration --version 9.3.0-preview.1.25265.20
#r "nuget: Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration, 9.3.0-preview.1.25265.20"
#addin nuget:?package=Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration&version=9.3.0-preview.1.25265.20&prerelease
#tool nuget:?package=Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration&version=9.3.0-preview.1.25265.20&prerelease
Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration
Retrieves configuration settings from Azure App Configuration to use in your application. Registers Azure App Configuration service as a configuration source. Enables corresponding logging.
Getting started
Prerequisites
- Azure subscription - create one for free
- Azure App Configuration - create one.
Install the package
Install the .NET Aspire Azure App Configuration library with NuGet:
dotnet add package Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration
Usage examples
Add App Configuration to configuration
In the Program.cs file of your project, call the builder.Configuration.AddAzureAppConfiguration
extension method to add key-values from Azure App Configuration to the application's Configuration. The method takes a connection name parameter.
builder.AddAzureAppConfiguration("appConfig");
You can then retrieve a key-value through normal IConfiguration
APIS. For example, to retrieve a key-value from a Web API controller:
public MyController(IConfiguration configuration)
{
string someValue = configuration["someKey"];
}
Use feature flags
To use feature flags, install the Feature Management library:
dotnet add package Microsoft.FeatureManagement
App Configuration will not load feature flags by default. To load feature flags, you can pass the Action<AzureAppConfigurationOptions> configureOptions
delegate when calling builder.AddAzureAppConfiguration
.
builder.AddAzureAppConfiguration(
"appConfig",
configureOptions: options => options.UseFeatureFlags());
// Register feature management services
builder.Services.AddFeatureManagement();
You can then use IVariantFeatureManager
to evaluate feature flags in your application:
private readonly IVariantFeatureManager _featureManager;
public MyController(IVariantFeatureManager featureManager)
{
_featureManager = featureManager;
}
[HttpGet]
public async Task<IActionResult> Get()
{
if (await _featureManager.IsEnabledAsync("NewFeature"))
{
return Ok("New feature is enabled!");
}
return Ok("Using standard implementation.");
}
For information about using the Feature Management library, please go to the documentation.
Configuration
The .NET Aspire Azure App Configuration library provides multiple options to configure the Azure App Configuration connection based on the requirements and conventions of your project. Note that the App Config endpoint is required to be supplied, either in AzureAppConfigurationSettings.Endpoint
or using a connection string.
Use a connection string
When using a connection string from the ConnectionStrings
configuration section, you can provide the name of the connection string when calling builder.AddAzureAppConfiguration()
:
builder.AddAzureAppConfiguration("appConfigConnectionName");
And then the App Configuration endpoint will be retrieved from the ConnectionStrings
configuration section. The App Configuration store URI works with the AzureAppConfigurationSettings.Credential
property to establish a connection. If no credential is configured, the DefaultAzureCredential is used.
{
"ConnectionStrings": {
"appConfigConnectionName": "https://{store_name}.azconfig.io"
}
}
Use configuration providers
The .NET Aspire Azure App Configuration library supports Microsoft.Extensions.Configuration. It loads the AzureAppConfigurationSettings
from configuration by using the Aspire:Microsoft:Extensions:Configuration:AzureAppConfiguration
key. Example appsettings.json
that configures some of the options:
{
Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration
"Aspire": {
"Microsoft": {
"Extensions": {
"Configuration": {
"AzureAppConfiguration": {
"Endpoint": "YOUR_APPCONFIGURATION_ENDPOINT_URI"
}
}
}
}
}
}
Use inline delegates
You can also pass the Action<AzureAppConfigurationSettings> configureSettings
delegate to set up some or all the options inline, for example to set App Configuration endpoint from code:
builder.AddAzureAppConfiguration("appConfig", configureSettings: settings => settings.Endpoint = "http://YOUR_URI");
AppHost extensions
In your AppHost project, install the Aspire Azure App Configuration Hosting library with NuGet:
dotnet add package Aspire.Hosting.Azure.AppConfiguration
Then, in the Program.cs file of AppHost
, add a App Configuration connection and consume the connection using the following methods:
// Service registration
var appConfig = builder.AddAzureAppConfiguration("appConfig");
// Service consumption
var myService = builder.AddProject<Projects.MyService>()
.WithReference(appConfig);
The AddAzureAppConfiguration
method adds an Azure App Configuration resource to the builder. Or AddConnectionString
can be used to read connection information from the AppHost's configuration under the ConnectionStrings:appConfig
config key. The WithReference
method passes that connection information into a connection string named appConfig
in the MyService
project. In the Program.cs file of MyService
, the connection can be consumed using:
builder.AddAzureAppConfiguration("appConfig");
Additional documentation
- https://learn.microsoft.com/azure/azure-app-configuration/
- https://github.com/dotnet/aspire/tree/main/src/Components/README.md
Feedback & contributing
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Azure.Core (>= 1.46.0)
- Azure.Identity (>= 1.13.2)
- Azure.Security.KeyVault.Secrets (>= 4.7.0)
- DnsClient (>= 1.8.0)
- Microsoft.Extensions.Azure (>= 1.11.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.1.2)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.15)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Primitives (>= 8.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.3.1-preview.1.25305.6 | 224 | 6/10/2025 |
9.3.0-preview.1.25265.20 | 854 | 5/19/2025 |