Smp.Core.AzureAppConfiguration
1.0.2
See the version list below for details.
dotnet add package Smp.Core.AzureAppConfiguration --version 1.0.2
NuGet\Install-Package Smp.Core.AzureAppConfiguration -Version 1.0.2
<PackageReference Include="Smp.Core.AzureAppConfiguration" Version="1.0.2" />
<PackageVersion Include="Smp.Core.AzureAppConfiguration" Version="1.0.2" />
<PackageReference Include="Smp.Core.AzureAppConfiguration" />
paket add Smp.Core.AzureAppConfiguration --version 1.0.2
#r "nuget: Smp.Core.AzureAppConfiguration, 1.0.2"
#:package Smp.Core.AzureAppConfiguration@1.0.2
#addin nuget:?package=Smp.Core.AzureAppConfiguration&version=1.0.2
#tool nuget:?package=Smp.Core.AzureAppConfiguration&version=1.0.2
Smp.Core.AzureAppConfiguration
A simplified Azure App Configuration provider for .NET applications. This package wraps Microsoft.Extensions.Configuration.AzureAppConfiguration with opinionated defaults, making it easy to load keys from one or more Azure App Configuration stores — with environment-label support and Azure Key Vault reference resolution — using a single appsettings.json block.
Table of Contents
- Installation
- How It Works
- Authentication Setup
- appsettings.json Configuration
- Usage by Project Type
- Key Selection and Labels
- Multiple Stores
Installation
dotnet add package Smp.Core.AzureAppConfiguration
How It Works
The package exposes a single extension method on IConfigurationBuilder, living in the Microsoft.Extensions.Configuration.AzureAppConfiguration namespace so no extra using statement is required:
IConfigurationBuilder AddAppConfiguration(bool? addAppSettings = default, string? hostEnvironment = default)
| Parameter | Type | Default | Description |
|---|---|---|---|
addAppSettings |
bool? |
false |
When true, loads appsettings.json and appsettings.{hostEnvironment}.json before connecting to Azure. Only needed when the host does not load these files automatically (e.g., Azure Functions with new HostBuilder()). |
hostEnvironment |
string? |
null |
The environment name (e.g., "Development", "Production"). Used to load appsettings.{env}.json and to select environment-labeled keys from Azure App Configuration. |
The method reads the AppConfigurations array from the loaded configuration and connects to each Azure App Configuration endpoint via DefaultAzureCredential, selecting the specified keys. If no endpoints are configured it returns immediately without connecting to Azure.
Authentication Setup
This package uses DefaultAzureCredential, which resolves credentials in the following order:
- Environment variables
- Workload Identity (AKS)
- Managed Identity (Azure-hosted apps)
- Visual Studio credential
- Azure CLI credential (
az login) - Azure PowerShell credential
Local development: Sign in with az login or through Visual Studio → Tools → Options → Azure Service Authentication.
Deployed environments: Assign the application's Managed Identity the App Configuration Data Reader role on each Azure App Configuration resource. If keys reference Azure Key Vault secrets, also assign the Key Vault Secrets User role on the relevant vaults.
appsettings.json Configuration
Add an AppConfigurations array to appsettings.json. Each element targets one Azure App Configuration store.
{
"AppConfigurations": [
{
"Endpoint": "https://<your-store-name>.azconfig.io",
"Keys": [
"*"
]
}
]
}
Configuration Properties
| Property | Type | Required | Description |
|---|---|---|---|
Endpoint |
string |
Yes | The full URL of the Azure App Configuration store. |
Keys |
string[] |
Yes | One or more key filters. Supports wildcards (e.g., *, MyApp:*). |
Key Filter Examples
| Filter | Selects |
|---|---|
* |
All keys in the store |
MyApp:* |
All keys with the MyApp: prefix |
MyApp:Database:ConnectionString |
A single specific key |
Usage by Project Type
ASP.NET Core (Web API / MVC / Minimal API)
WebApplication.CreateBuilder automatically loads appsettings.json and appsettings.{env}.json, so only hostEnvironment needs to be provided.
Modify Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddAppConfiguration(hostEnvironment: builder.Environment.EnvironmentName);
// ... register services
var app = builder.Build();
// ... configure pipeline
app.Run();
appsettings.json — add the AppConfigurations section alongside your existing configuration:
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
"AppConfigurations": [
{
"Endpoint": "https://<your-store-name>.azconfig.io",
"Keys": [ "MyApp:*" ]
}
]
}
Worker Service / Console (.NET Generic Host)
Both Host.CreateApplicationBuilder and Host.CreateDefaultBuilder automatically load appsettings.json and appsettings.{env}.json, so only hostEnvironment needs to be provided.
Using Host.CreateApplicationBuilder (.NET 8+)
var builder = Host.CreateApplicationBuilder(args);
builder.Configuration
.AddAppConfiguration(hostEnvironment: builder.Environment.EnvironmentName);
builder.Services.AddHostedService<Worker>();
var host = builder.Build();
host.Run();
Using Host.CreateDefaultBuilder
var host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
config.AddAppConfiguration(hostEnvironment: context.HostingEnvironment.EnvironmentName);
})
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
})
.Build();
host.Run();
appsettings.json:
{
"AppConfigurations": [
{
"Endpoint": "https://<your-store-name>.azconfig.io",
"Keys": [ "MyWorker:*" ]
}
]
}
Azure Functions (Isolated Worker)
new HostBuilder() does not load any JSON files automatically. Pass addAppSettings: true so the method loads appsettings.json before connecting to Azure.
In Program.cs:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureAppConfiguration((context, config) =>
{
config.AddAppConfiguration(addAppSettings: true, hostEnvironment: context.HostingEnvironment.EnvironmentName);
})
.Build();
host.Run();
local.settings.json — used only for local development and not deployed:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
appsettings.json — Azure Functions projects do not include this file by default. Create it at the project root:
{
"AppConfigurations": [
{
"Endpoint": "https://<your-store-name>.azconfig.io",
"Keys": [ "MyFunction:*" ]
}
]
}
Because the Functions runtime reads files from the output directory, appsettings.json must be copied on every build. Add the following ItemGroup to your .csproj:
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Key Selection and Labels
When hostEnvironment is provided, keys are loaded in two passes:
- No label (null) — loads the shared default value for each key.
- Environment label — loads the environment-specific value (e.g.,
Development,Staging,Production), which overrides the default.
This means you can store a default value in Azure App Configuration with no label and then override it per environment by adding the same key with the appropriate label.
Example for key MyApp:ApiUrl:
| Key | Label | Value |
|---|---|---|
MyApp:ApiUrl |
(none) | https://api.default.example.com |
MyApp:ApiUrl |
Production |
https://api.example.com |
When running in Production, the app receives https://api.example.com. In any other environment it falls back to https://api.default.example.com.
Multiple Stores
To pull keys from more than one Azure App Configuration store, add additional entries to the AppConfigurations array:
{
"AppConfigurations": [
{
"Endpoint": "https://<shared-store>.azconfig.io",
"Keys": [ "Shared:*" ]
},
{
"Endpoint": "https://<app-store>.azconfig.io",
"Keys": [ "MyApp:*" ]
}
]
}
Stores are processed in array order. If the same key exists in multiple stores, the last store wins.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Azure.Identity (>= 1.20.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 8.5.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Microsoft.Extensions.Configuration.Json (>= 10.0.5)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.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.