From 63c08ff61a490f95a87a8e577d02c3c73519eab6 Mon Sep 17 00:00:00 2001 From: David Pine Date: Tue, 2 Dec 2025 10:26:50 -0600 Subject: [PATCH 1/4] fix: Update Azure App Configuration documentation to clarify connection methods and emulator usage - fixes #106 --- .../cloud/azure/azure-app-configuration.mdx | 286 +++++++++++------- 1 file changed, 173 insertions(+), 113 deletions(-) diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx index eef5e1ebe1..0988f5a558 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx @@ -155,171 +155,238 @@ builder.Build().Run(); For more information, see [Use existing Azure resources](/integrations/cloud/azure/overview/#use-existing-azure-resources). -### Connect to an existing Azure App Configuration instance +### Connect to existing Azure App Configuration store -You might have an existing Azure App Configuration service that you want to connect to. You can chain a call to annotate that your `AzureAppConfigurationResource` is an existing resource: +An alternative approach to using the `*AsExisting` APIs enables the addition of a connection string instead, where the AppHost uses configuration to resolve the connection information. To add a connection to an existing Azure App Configuration store, call the `AddConnectionString` method: -```csharp title="C# β€” AppHost.cs" +```csharp var builder = DistributedApplication.CreateBuilder(args); -var existingAppConfigName = builder.AddParameter("existingAppConfigName"); -var existingAppConfigResourceGroup = builder.AddParameter("existingAppConfigResourceGroup"); +var config = builder.AddConnectionString("config"); -var appConfig = builder.AddAzureAppConfiguration("app-config") - .AsExisting(existingAppConfigName, existingAppConfigResourceGroup); - -builder.AddProject() - .WithReference(appConfig); +builder.AddProject("web") + .WithReference(config); // After adding all resources, run the app... ``` -For more information on treating Azure App Configuration resources as existing resources, see [Use existing Azure resources](/integrations/cloud/azure/overview/#use-existing-azure-resources). +> [!NOTE] +> Connection strings are used to represent a wide range of connection information, including database connections, message brokers, endpoint URIs, and other services. In Aspire nomenclature, the term "connection string" is used to represent any kind of connection information. - +The connection string is configured in the AppHost's configuration, typically under [User Secrets](/aspnet/core/security/app-secrets), under the `ConnectionStrings` section. The AppHost injects this connection string as an environment variable into all dependent resources, for example: -### Provisioning-generated Bicep - -When you publish your app, Aspire provisioning APIs generate Bicep alongside the manifest file. Bicep is a domain-specific language for defining Azure resources. For more information, see [Bicep Overview](https://learn.microsoft.com/azure-resource-manager/bicep/overview). +```json +{ + "ConnectionStrings": { + "config": "https://{store_name}.azconfig.io" + } +} +``` -When you add an Azure App Configuration resource, Bicep is generated that provisions the resource. The generated Bicep is a starting point and is influenced by changes to the provisioning infrastructure in C#. Customizations to the Bicep file directly will be overwritten, so make changes through the C# provisioning APIs to ensure they are reflected in the generated files. +The dependent resource can access the injected connection string by calling the `GetConnectionString` method, and passing the connection name as the parameter, in this case `"config"`. The `GetConnectionString` API is shorthand for `IConfiguration.GetSection("ConnectionStrings")[name]`. -#### Customize provisioning infrastructure +### Add Azure App Configuration emulator resource -All Aspire Azure resources are subclasses of the `AzureProvisioningResource` type. This type enables the customization of the generated Bicep by providing a fluent API to configure the Azure resources using the `ConfigureInfrastructure` API: +Microsoft provide the Azure App Configuration emulator for developers who want a local, lightweight implementation of the Azure App Configuration service to code and test against. In Aspire, you can use this emulator by calling the `RunAsEmulator` method when you add your resource: ```csharp title="C# β€” AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); -var appConfig = builder.AddAzureAppConfiguration("app-config"); +var appConfig = builder.AddAzureAppConfiguration("config") + .RunAsEmulator(); -appConfig.ConfigureInfrastructure(infra => -{ - var configStore = infra.GetProvisionableResources() - .OfType() - .Single(); +// After adding all resources, run the app... - configStore.Sku = new AppConfigurationStoreSku +builder.Build().Run(); +``` + +The Azure App Configuration emulator isn't installed on your local computer. Instead, it's accessible to Aspire as a container. The `RunAsEmulator` method creates and starts the container when the AppHost starts using the `azure-app-configuration/app-configuration-emulator` image. + +#### Configure Azure App Configuration emulator container + +There are various configurations available to container resources. For example, you can configure the container's port, environment variables, it's lifetime, and more. + +##### Configure Azure App Configuration emulator host port + +By default, Aspire assigns a random host port for the emulator container. If you want to use a specific port, chain calls on the container resource builder provided by the `RunAsEmulator` method as shown in the following example: + +```csharp title="C# β€” AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var appConfig = builder.AddAzureAppConfiguration("config") + .RunAsEmulator(emulator => { - Name = "Standard" - }; - configStore.Tags["ExampleKey"] = "Example value"; -}); + emulator.WithHostPort(28000); + }); + +// After adding all resources, run the app... ``` -The preceding code: +The preceding code configures the emulator container's endpoint to listen on ports `28000`. -- Chains a call to the `ConfigureInfrastructure` API: - - The `infra` parameter is an instance of the `AzureResourceInfrastructure` type. - - The provisionable resources are retrieved by calling the `GetProvisionableResources` method. - - The single `AppConfigurationStore` resource is retrieved. - - The `Sku` object has its name property set to `Standard`. - - A tag is added to the App Configuration resource with a key of `ExampleKey` and a value of `Example value`. +##### Configure Azure App Configuration emulator with persistent lifetime -There are many more configuration options available to customize the App Configuration resource. For more information, see [Azure.Provisioning customization](/integrations/cloud/azure/customize-resources/#azureprovisioning-customization). +To configure the emulator container with a persistent lifetime, call the `WithLifetime` method on the emulator container resource and pass `ContainerLifetime.Persistent`: -## Client integration +```csharp title="C# β€” AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); -The Aspire Azure App Configuration client integration is used to connect to an Azure App Configuration service. To get started with the Aspire Azure App Configuration client integration, install the [πŸ“¦ Aspire.Azure.Data.AppConfiguration](https://www.nuget.org/packages/Aspire.Azure.Data.AppConfiguration) NuGet package. +var appConfig = builder.AddAzureAppConfiguration("config") + .RunAsEmulator(emulator => + { + emulator.WithLifetime(ContainerLifetime.Persistent); + }); - +// After adding all resources, run the app... +``` -### Add App Configuration client +##### Configure Azure App Configuration emulator with data volume -In the `Program.cs` file of your client-consuming project, call the `AddAzureAppConfiguration` extension method to register a `ConfigurationClient` for use via the dependency injection container. The method takes a connection name parameter: +To add a data volume to the Azure App Configuration emulator resource, call the `WithDataVolume` method on the emulator resource: ```csharp -builder.AddAzureAppConfiguration(connectionName: "app-config"); +var builder = DistributedApplication.CreateBuilder(args); + +var appConfig = builder.AddAzureAppConfiguration("config") + .RunAsEmulator(emulator => + { + emulator.WithDataVolume(); + }); + +// After adding all resources, run the app... ``` - +The data volume is used to persist the emulator data outside the lifecycle of its container. The data volume is mounted at the `/data` path in the emulator container and when a `name` parameter isn't provided, the name is autogenerated from the application and resource names. For more information on data volumes and details on why they're preferred over [bind mounts](#configure-azure-app-configuration-emulator-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). -After adding the `ConfigurationClient`, you can retrieve the client instance using dependency injection: +##### Configure Azure App Configuration emulator with data bind mount -```csharp -public class ExampleService(ConfigurationClient client) -{ - // Use client... -} +To add a data bind mount to the Azure App Configuration emulator resource, call the `WithDataBindMount` method: + +```csharp title="C# β€” AppHost.cs" +var builder = DistributedApplication.CreateBuilder(args); + +var appConfig = builder.AddAzureAppConfiguration("config") + .RunAsEmulator(emulator => + { + emulator.WithDataBindMount("../Emulator/Data"); + }); + +// After adding all resources, run the app... ``` -For more information, see: +> [!IMPORTANT] +> Data [bind mounts](https://docs.docker.com/engine/storage/bind-mounts/) have limited functionality compared to [volumes](https://docs.docker.com/engine/storage/volumes/), which offer better performance, portability, and security, making them more suitable for production environments. However, bind mounts allow direct access and modification of files on the host system, ideal for development and testing where real-time changes are needed. + +Data bind mounts rely on the host machine's filesystem to persist the emulator data across container restarts. The data bind mount is mounted at the `../Emulator/Data` path on the host machine relative to the AppHost directory (`IDistributedApplicationBuilder.AppHostDirectory`) in the emulator container. For more information on data bind mounts, see [Docker docs: Bind mounts](https://docs.docker.com/engine/storage/bind-mounts). -- [Azure.Data.AppConfiguration documentation](https://learn.microsoft.com/dotnet/api/azure.data.appconfiguration.configurationclient) for examples on using the `ConfigurationClient`. -- [Dependency injection in .NET](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection) for details on dependency injection. +## Client integration -### Add keyed App Configuration client +To get started with the Aspire Azure App Configuration client integration, install the [πŸ“¦ Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration](https://www.nuget.org/packages/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration) NuGet package in the client-consuming project, that is, the project for the application that uses the App Configuration client. The App Configuration client integration registers an Azure configuration provider to populate the `IConfiguration` instance. -There might be situations where you want to register multiple `ConfigurationClient` instances with different connection names. To register keyed App Configuration clients, call the `AddKeyedAzureAppConfiguration` method: + -```csharp -builder.AddKeyedAzureAppConfiguration(name: "primary-config"); -builder.AddKeyedAzureAppConfiguration(name: "secondary-config"); +In the `Program.cs` file of your client-consuming project, call the `AddAzureAppConfiguration` extension method on any `IHostApplicationBuilder` to register the required services to flow Azure App Configuration values into the `IConfiguration` instance for use via the dependency injection container. The method takes a connection name parameter. + +```csharp title="C# β€” Program.cs" +builder.AddAzureAppConfiguration(connectionName: "config"); ``` -Then you can retrieve the client instances using dependency injection: +> [!TIP] +> The `connectionName` parameter must match the name used when adding the App Configuration resource in the AppHost project. In other words, when you call `AddAzureAppConfiguration` in the AppHost and provide a name of `config` that same name should be used when calling `AddAzureAppConfiguration` in the client-consuming project. For more information, see [Add Azure App Configuration resource](#add-azure-app-configuration-resource). -```csharp -public class ExampleService( - [KeyedService("primary-config")] ConfigurationClient primaryClient, - [KeyedService("secondary-config")] ConfigurationClient secondaryClient) +You can then retrieve the `IConfiguration` instance using dependency injection. For example, to retrieve the client from an example service: + +```csharp title="C# β€” ExampleService.cs" +public class ExampleService(IConfiguration configuration) { - // Use clients... + private readonly string _someValue = configuration["SomeKey"]; } ``` -For more information, see [Keyed services in .NET](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection#keyed-services). +### Use feature flags -### Configuration +To use feature flags, install the [πŸ“¦ Microsoft.FeatureManagement](https://www.nuget.org/packages/Microsoft.FeatureManagement) NuGet package: -The Aspire Azure App Configuration library provides multiple options to configure the Azure App Configuration connection based on the requirements and conventions of your project. Either an `Endpoint` or a `ConnectionString` must be supplied. + -#### Use a connection string +App Configuration doesn't load feature flags by default. To load feature flags, you pass the `Action configureOptions` delegate when calling `builder.AddAzureAppConfiguration`. -When using a connection string from the `ConnectionStrings` configuration section, you can provide the name of the connection string when calling `AddAzureAppConfiguration`: +```csharp title="C# β€” Program.cs" +builder.AddAzureAppConfiguration( + "config", + configureOptions: options => options.UseFeatureFlags()); -```csharp -builder.AddAzureAppConfiguration(connectionName: "app-config"); +// Register feature management services +builder.Services.AddFeatureManagement(); ``` -The connection information is retrieved from the `ConnectionStrings` configuration section. Two connection formats are supported: +You can then use `IFeatureManager` to evaluate feature flags in your app. Consider the following example ASP.NET Core Minimal API app: -- **Service endpoint (recommended)**: Uses the service endpoint with `DefaultAzureCredential`. +```csharp title="C# β€” Program.cs" +using Microsoft.Extensions.Hosting; +using Microsoft.FeatureManagement; - ```json - { - "ConnectionStrings": { - "app-config": "https://{account_name}.azconfig.io" - } - } - ``` +var builder = WebApplication.CreateBuilder(args); + +builder.AddAzureAppConfiguration( + "config", + configureOptions: options => options.UseFeatureFlags()); + +// Register feature management services +builder.Services.AddFeatureManagement(); -- **Connection string**: Includes an access key. +var app = builder.Build(); - ```json +app.MapGet("/", async (IFeatureManager featureManager) => +{ + if (await featureManager.IsEnabledAsync("NewFeature")) { - "ConnectionStrings": { - "app-config": "Endpoint=https://{account_name}.azconfig.io;Id={id};Secret={secret}" - } + return Results.Ok("New feature is enabled!"); } - ``` + + return Results.Ok("Using standard implementation."); +}); + +app.Run(); +``` + +For more information, see [.NET Feature Management](https://learn.microsoft.com/azure/azure-app-configuration/feature-management-dotnet-reference). + +### Configuration + +The Aspire Azure App Configuration library provides multiple options to configure the Azure App Configuration connection based on the requirements and conventions of your project. 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()`: + +```csharp title="C# β€” Program.cs" +builder.AddAzureAppConfiguration("config"); +``` + +Then the App Configuration endpoint is 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. + +```json title="JSON β€” appsettings.json" +{ + "ConnectionStrings": { + "config": "https://{store_name}.azconfig.io" + } +} +``` #### Use configuration providers -The library supports `Microsoft.Extensions.Configuration`. It loads settings from configuration using the `Aspire:Azure:Data:AppConfiguration` key: +The 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: -```json +```json title="JSON β€” appsettings.json" { "Aspire": { - "Azure": { - "Data": { - "AppConfiguration": { - "DisableHealthChecks": true, - "DisableTracing": false + "Microsoft": { + "Extensions": { + "Configuration": { + "AzureAppConfiguration": { + "Endpoint": "YOUR_APPCONFIGURATION_ENDPOINT_URI" + } } } } @@ -327,35 +394,28 @@ The library supports `Microsoft.Extensions.Configuration`. It loads settings fro } ``` +For the complete App Configuration client integration JSON schema, see [ConfigurationSchema.json](https://github.com/dotnet/aspire/blob/main/src/Components/Aspire.Microsoft.Extensions.Configuration.AzureAppConfiguration/ConfigurationSchema.json). + #### Use inline delegates -You can configure settings inline: +You can also pass the `Action configureSettings` delegate to set up some or all the options inline, for example to set App Configuration endpoint from code: -```csharp +```csharp title="C# β€” Program.cs" builder.AddAzureAppConfiguration( - "app-config", - settings => settings.DisableHealthChecks = true); + "config", + configureSettings: settings => settings.Endpoint = "http://YOUR_URI"); ``` -### Observability and telemetry - -Aspire integrations automatically set up Logging, Tracing, and Metrics configurations. - #### Logging The Aspire Azure App Configuration integration uses the following log categories: -- `Azure` -- `Azure.Core` -- `Azure.Identity` -- `Azure.Data.AppConfiguration` +- `Microsoft.Extensions.Configuration.AzureAppConfiguration.Refresh` #### Tracing -The Aspire Azure App Configuration integration will emit the following tracing activities using OpenTelemetry: - -- `Azure.Data.AppConfiguration.*` +The Aspire Azure App Configuration integration doesn't make use any activity sources thus no tracing is available. #### Metrics -The Aspire Azure App Configuration integration currently doesn't support metrics by default due to limitations with the Azure SDK for .NET. +The Aspire Azure App Configuration integration currently doesn't support metrics. From 13abb8e62807d565d79c539902111f118891829d Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 3 Dec 2025 11:40:09 -0600 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../cloud/azure/azure-app-configuration.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx index 0988f5a558..bcbe7827f0 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx @@ -187,7 +187,7 @@ The dependent resource can access the injected connection string by calling the ### Add Azure App Configuration emulator resource -Microsoft provide the Azure App Configuration emulator for developers who want a local, lightweight implementation of the Azure App Configuration service to code and test against. In Aspire, you can use this emulator by calling the `RunAsEmulator` method when you add your resource: +Microsoft provides the Azure App Configuration emulator for developers who want a local, lightweight implementation of the Azure App Configuration service to code and test against. In Aspire, you can use this emulator by calling the `RunAsEmulator` method when you add your resource: ```csharp title="C# β€” AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -204,7 +204,7 @@ The Azure App Configuration emulator isn't installed on your local computer. Ins #### Configure Azure App Configuration emulator container -There are various configurations available to container resources. For example, you can configure the container's port, environment variables, it's lifetime, and more. +There are various configurations available to container resources. For example, you can configure the container's port, environment variables, its lifetime, and more. ##### Configure Azure App Configuration emulator host port @@ -222,7 +222,7 @@ var appConfig = builder.AddAzureAppConfiguration("config") // After adding all resources, run the app... ``` -The preceding code configures the emulator container's endpoint to listen on ports `28000`. +The preceding code configures the emulator container's endpoint to listen on port `28000`. ##### Configure Azure App Configuration emulator with persistent lifetime @@ -256,7 +256,7 @@ var appConfig = builder.AddAzureAppConfiguration("config") // After adding all resources, run the app... ``` -The data volume is used to persist the emulator data outside the lifecycle of its container. The data volume is mounted at the `/data` path in the emulator container and when a `name` parameter isn't provided, the name is autogenerated from the application and resource names. For more information on data volumes and details on why they're preferred over [bind mounts](#configure-azure-app-configuration-emulator-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). +The data volume is used to persist the emulator data outside the lifecycle of its container. The data volume is mounted at the `/data` path in the emulator container and when a `name` parameter isn't provided, the name is autogenerated from the application and resource names (for example, if your application is named `myapp` and the resource is `config`, the autogenerated name will be `myapp-config`). For more information on data volumes and details on why they're preferred over [bind mounts](#configure-azure-app-configuration-emulator-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). ##### Configure Azure App Configuration emulator with data bind mount @@ -403,7 +403,7 @@ You can also pass the `Action configureSettings` ```csharp title="C# β€” Program.cs" builder.AddAzureAppConfiguration( "config", - configureSettings: settings => settings.Endpoint = "http://YOUR_URI"); + configureSettings: settings => settings.Endpoint = "https://YOUR_URI"); ``` #### Logging @@ -414,7 +414,7 @@ The Aspire Azure App Configuration integration uses the following log categories #### Tracing -The Aspire Azure App Configuration integration doesn't make use any activity sources thus no tracing is available. +The Aspire Azure App Configuration integration doesn't make use of any activity sources thus no tracing is available. #### Metrics From 54eeaf4ba8285c4de16c9946fae670d066ea885f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 11:41:42 -0600 Subject: [PATCH 3/4] Address review feedback for Azure App Configuration documentation (#119) * Initial plan * Address zhiyuanliang-ms review feedback: add configureOptions section, clarify data persistence Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> * Improve readability per code review feedback Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> * Fix formatting and update import statements in MDX --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> Co-authored-by: David Pine --- .../cloud/azure/azure-app-configuration.mdx | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx index bcbe7827f0..72643992fa 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx @@ -14,7 +14,7 @@ import appConfigIcon from '@assets/icons/azure-appconfig-icon.png'; alt="Azure App Configuration logo" height={80} width={80} - class:list={'float-inline-left icon'} + class:list={"float-inline-left icon"} data-zoom-off /> @@ -242,7 +242,7 @@ var appConfig = builder.AddAzureAppConfiguration("config") ##### Configure Azure App Configuration emulator with data volume -To add a data volume to the Azure App Configuration emulator resource, call the `WithDataVolume` method on the emulator resource: +By default, the Azure App Configuration emulator doesn't persist data between container restarts. To enable persistent storage using a Docker volume, call the `WithDataVolume` method on the emulator resource: ```csharp var builder = DistributedApplication.CreateBuilder(args); @@ -256,11 +256,11 @@ var appConfig = builder.AddAzureAppConfiguration("config") // After adding all resources, run the app... ``` -The data volume is used to persist the emulator data outside the lifecycle of its container. The data volume is mounted at the `/data` path in the emulator container and when a `name` parameter isn't provided, the name is autogenerated from the application and resource names (for example, if your application is named `myapp` and the resource is `config`, the autogenerated name will be `myapp-config`). For more information on data volumes and details on why they're preferred over [bind mounts](#configure-azure-app-configuration-emulator-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). +The data volume is used to persist the emulator data outside the lifecycle of its container, ensuring configuration values survive container restarts. The data volume is mounted at the `/data` path in the emulator container and when a `name` parameter isn't provided, the name is autogenerated from the application and resource names (for example, if your application is named `myapp` and the resource is `config`, the autogenerated name will be `myapp-config`). For more information on data volumes and details on why they're preferred over [bind mounts](#configure-azure-app-configuration-emulator-with-data-bind-mount), see [Docker docs: Volumes](https://docs.docker.com/engine/storage/volumes). ##### Configure Azure App Configuration emulator with data bind mount -To add a data bind mount to the Azure App Configuration emulator resource, call the `WithDataBindMount` method: +To persist emulator data to a specific directory on your host machine, call the `WithDataBindMount` method. This is useful when you want direct access to the data files on your host system: ```csharp title="C# β€” AppHost.cs" var builder = DistributedApplication.CreateBuilder(args); @@ -303,13 +303,37 @@ public class ExampleService(IConfiguration configuration) } ``` +### Configure the Azure App Configuration provider + +The `AddAzureAppConfiguration` method accepts an optional `Action configureOptions` delegate that you use to configure the Azure App Configuration provider. This follows the same pattern as the non-Aspire `Microsoft.Extensions.Configuration.AzureAppConfiguration` package, but Aspire automatically handles the connectionβ€”you don't need to call `options.Connect`. + +```csharp title="C# β€” Program.cs" +builder.AddAzureAppConfiguration( + "config", + configureOptions: options => + { + // Select specific keys or labels + options.Select("MyApp:*"); + options.Select("MyApp:*", "Production"); + + // Configure refresh options + options.ConfigureRefresh(refresh => + { + refresh.Register("MyApp:Sentinel", refreshAll: true) + .SetRefreshInterval(TimeSpan.FromSeconds(30)); + }); + }); +``` + +For more information on available configuration options, see the [Azure App Configuration provider reference](https://learn.microsoft.com/azure/azure-app-configuration/reference-dotnet-provider). + ### Use feature flags To use feature flags, install the [πŸ“¦ Microsoft.FeatureManagement](https://www.nuget.org/packages/Microsoft.FeatureManagement) NuGet package: -App Configuration doesn't load feature flags by default. To load feature flags, you pass the `Action configureOptions` delegate when calling `builder.AddAzureAppConfiguration`. +App Configuration doesn't load feature flags by default. To load feature flags, use the `configureOptions` delegate (as shown in [Configure the Azure App Configuration provider](#configure-the-azure-app-configuration-provider)) to call `UseFeatureFlags()` when calling `builder.AddAzureAppConfiguration`. ```csharp title="C# β€” Program.cs" builder.AddAzureAppConfiguration( From 9e9fff32cd91e9132dea54657c7677fd1ac8fe08 Mon Sep 17 00:00:00 2001 From: David Pine Date: Fri, 5 Dec 2025 11:51:34 -0600 Subject: [PATCH 4/4] Apply suggestions from code review --- .../docs/integrations/cloud/azure/azure-app-configuration.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx index 72643992fa..31bfd3fdc7 100644 --- a/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx +++ b/src/frontend/src/content/docs/integrations/cloud/azure/azure-app-configuration.mdx @@ -344,7 +344,7 @@ builder.AddAzureAppConfiguration( builder.Services.AddFeatureManagement(); ``` -You can then use `IFeatureManager` to evaluate feature flags in your app. Consider the following example ASP.NET Core Minimal API app: +The `configureOptions` pattern is used to configure the Azure App Configuration provider. For more information, see [Azure App Configuration: .NET configuration provider](https://learn.microsoft.com/azure/azure-app-configuration/reference-dotnet-provider). You can then use `IFeatureManager` to evaluate feature flags in your app. Consider the following example ASP.NET Core Minimal API app: ```csharp title="C# β€” Program.cs" using Microsoft.Extensions.Hosting;