### Install Go Dependencies Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ChatApp/README.md Run this command after initializing your Go module to download and install all necessary project dependencies. ```bash go mod tidy ``` -------------------------------- ### Install .NET Packages Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/ChatAgent/README.md Run this command in your project directory to restore and install necessary .NET packages. ```bash dotnet restore ``` -------------------------------- ### Console Application Output Example Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/ConsoleAppWithTableStorageReference/README.md Example output from the console application, displaying product information retrieved from Azure Table Storage. ```output Product table: Name = Ocean Surfboard Quantity = 8 Name = Sand Surfboard Quantity = 5 ``` -------------------------------- ### Clone Repository and Navigate to Directory Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/ChatAgent/README.md Use this command to clone the repository and navigate to the example's directory. ```bash git clone https://github.com/Azure/AppConfiguration.git cd examples\DotNetCore\ChatAgent ``` -------------------------------- ### Example Chat Session Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ChatApp/README.md This is an example of an interactive chat session with the Go application. It shows user input and AI responses, demonstrating conversation flow and the exit command. ```text Chat started! What's on your mind? You: Hello, how are you? AI: Hello! I'm doing well, thank you for asking. How can I help you today? You: What can you tell me about machine learning? AI: Machine learning is a subset of artificial intelligence that focuses on... You: [Press Enter to exit] Exiting chat. Goodbye! ``` -------------------------------- ### Clone Repository and Navigate Directory Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatAgent/README.md Clone the Azure AppConfiguration repository and navigate to the Python chat agent example directory. ```bash git clone https://github.com/Azure/AppConfiguration.git cd examples\/Python\/ChatAgent ``` -------------------------------- ### Integrate Azure App Configuration with Azure Front Door Source: https://context7.com/azure/appconfiguration/llms.txt These C# examples show how to configure Azure App Configuration to use Azure Front Door for CDN-accelerated delivery. They cover basic setup, specific key-value selectors, feature flags, and tag filters. ```csharp // Basic setup with default key-values builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` ```csharp // With specific key-value selectors builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` ```csharp // With key-values and feature flags builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }) .UseFeatureFlags(ffOptions => { ffOptions.Select("MyFeatures*") .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` ```csharp // With tag filters builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*", tagFilters: new[] { "Env=Dev" }) .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Create and Activate Python Virtual Environment (macOS/Linux) Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatAgent/README.md Create a Python virtual environment and activate it for installing project dependencies. ```bash python -m venv .venv source .venv/bin/activate ``` -------------------------------- ### Install Python Packages Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatApp/README.md Installs the necessary Python packages for the application. Ensure you have Python 3.9 or later. ```bash pip install -r requirements.txt ``` -------------------------------- ### Create and Activate Python Virtual Environment (Windows) Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatAgent/README.md Create a Python virtual environment and activate it for installing project dependencies. ```cmd python -m venv .venv .venv\scripts\activate ``` -------------------------------- ### Configure Key Vault References with SecretClient Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md This example demonstrates the updated method for configuring Key Vault references using `ConfigureKeyVault` with a `SecretClient`, replacing the older `UseAzureKeyVault` method. ```csharp SecretClient secretClient = CreateSecretClient(); IConfigurationBuilder configBuilder = new ConfigurationBuilder(); IConfiguration configuration = configBuilder.AddAzureAppConfiguration(options => { options.Connect(endpoint, new ManagedIdentityCredential()); options.ConfigureKeyVault(kv => { kv.Register(secretClient); }); }).Build(); ``` -------------------------------- ### Run Flask Application Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/python-flask-webapp-sample/README.md Start the Flask application using the flask command. Ensure your environment is set up correctly. ```command line flask run ``` -------------------------------- ### Run Django Application Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/python-django-webapp-sample/README.md Start the Django development server after applying database migrations. The application will be accessible at http://127.0.0.1:8000. ```command line # Run database migration python manage.py migrate # Run the app at http://127.0.0.1:8000 python manage.py runserver ``` -------------------------------- ### Run the Chat Application Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatApp/README.md Starts the Python chat application. The application will load initial configurations, interact with the AI, and maintain conversation history. ```bash python app.py ``` -------------------------------- ### Example Chat Interaction Output Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatAgent/README.md Illustrates a sample user input and the AI agent's response, including weather information and source links. ```text How can I help? (type 'quit' to exit) User: What is the weather today in Seattle ? Agent response: Today in Seattle, expect steady rain throughout the day with patchy fog, and a high temperature around 57°F (14°C). Winds are from the south-southwest at 14 to 17 mph, with gusts as high as 29 mph. Flood and wind advisories are in effect due to ongoing heavy rain and saturated conditions. Rain is likely to continue into the night, with a low near 49°F. Please stay aware of weather alerts if you are traveling or in low-lying areas [National Weather Service Seattle](https://forecast.weather.gov/zipcity.php?inputstring=Seattle%2CWA) [The Weather Channel Seattle Forecast](https://weather.com/weather/today/l/Seattle+Washington?canonicalCityId=1138ce33fd1be51ab7db675c0da0a27c). Press enter to continue... ``` -------------------------------- ### Specify Labels for App Configuration Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/SpringCloudAzureAppConfigurationConfig.md Use '\0' to indicate keys with no labels, ensuring consistency with the service. This example loads keys with no labels and then overwrites them with keys from the 'dev' label. ```java spring.cloud.azure.appconfiguration.stores[0].label = \0,dev ``` -------------------------------- ### Connect to Azure Front Door with Key-Value Selector Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Configure your application to connect to Azure Front Door and load specific key-values using a prefix. Ensure your Azure Front Door filters are set to 'Key Starts with' with the specified prefix and '(No label)'. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Configure Key Vault References with TokenCredential Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Before version 3.0.0-preview-011100001-1152, Key Vault references were configured using `UseAzureKeyVault`. This example shows the updated approach using `ConfigureKeyVault` with a `TokenCredential`. ```csharp IConfigurationBuilder configBuilder = new ConfigurationBuilder(); IConfiguration configuration = configBuilder.AddAzureAppConfiguration(options => { options.Connect(endpoint, new DefaultAzureCredential()); options.ConfigureKeyVault(kv => { kv.SetCredential(new DefaultAzureCredential()); }); }).Build(); ``` -------------------------------- ### Load Key-Values and Snapshot Selectors with Azure Front Door Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Configure your application to load key-values and a specific snapshot from Azure App Configuration via Azure Front Door. This setup includes a refresh interval for the configuration. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .SelectSnapshot("MySnapshot") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Load Key-Values and Feature Flags with Azure Front Door Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Configure your application to load both key-values and feature flags from Azure App Configuration via Azure Front Door. This example selects key-values with a specific prefix and feature flags with another prefix, setting a refresh interval for both. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }) .UseFeatureFlags(ffOptions => { ffOptions.Select("MyFeatures*") .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Export Key-Values to JSON using Azure CLI Source: https://context7.com/azure/appconfiguration/llms.txt Exports key-values from an Azure App Configuration store to a local JSON file using the 'kvset' profile. Ensure the Azure CLI is installed and authenticated. ```bash # Export key-values to JSON file using kvset profile az appconfig kv export \ --name MyAppConfigStore \ --destination file \ --path ./config-export.json \ --format json \ --profile appconfig/kvset ``` -------------------------------- ### Initialize Go Module Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ChatApp/README.md Use this command to initialize a new Go module for your project. Ensure you replace 'chatapp-quickstart' with your desired module name. ```bash go mod init chatapp-quickstart ``` -------------------------------- ### Initialize Go Module Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ConsoleApp/README.md Initializes a new Go module for the project. Run this command in your project directory. ```bash go mod init console-example-refresh ``` -------------------------------- ### Run the Go Application Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ConsoleApp/README.md Compiles and runs the main Go application. Ensure the connection string environment variable is set. ```bash go run main.go ``` -------------------------------- ### Go Web App with Feature Flags (Gin Framework) Source: https://context7.com/azure/appconfiguration/llms.txt Build a web application with feature flag management using the Go provider and Gin framework. Ensure the AZURE_APPCONFIG_CONNECTION_STRING environment variable is set. ```go package main import ( "context" "fmt" "log" "net/http" "os" "github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration" "github.com/gin-gonic/gin" "github.com/microsoft/Featuremanagement-Go/featuremanagement" "github.com/microsoft/Featuremanagement-Go/featuremanagement/providers/azappconfig" ) type WebApp struct { featureManager *featuremanagement.FeatureManager appConfig *azureappconfiguration.AzureAppConfiguration } func main() { ctx := context.Background() appConfig, err := loadAzureAppConfiguration(ctx) if err != nil { log.Fatalf("Error loading configuration: %v", err) } // Create feature flag provider and manager featureFlagProvider, _ := azappconfig.NewFeatureFlagProvider(appConfig) featureManager, _ := featuremanagement.NewFeatureManager(featureFlagProvider, nil) app := &WebApp{featureManager: featureManager, appConfig: appConfig} r := gin.Default() r.Use(app.featureMiddleware()) r.LoadHTMLGlob("templates/*.html") r.GET("/", app.homeHandler) r.GET("/beta", app.betaHandler) r.Run(":8080") } func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.AzureAppConfiguration, error) { connectionString := os.Getenv("AZURE_APPCONFIG_CONNECTION_STRING") authOptions := azureappconfiguration.AuthenticationOptions{ ConnectionString: connectionString, } options := &azureappconfiguration.Options{ FeatureFlagOptions: azureappconfiguration.FeatureFlagOptions{ Enabled: true, Selectors: []azureappconfiguration.Selector{ {KeyFilter: "*", LabelFilter: ""}, }, RefreshOptions: azureappconfiguration.RefreshOptions{Enabled: true}, }, } return azureappconfiguration.Load(ctx, authOptions, options) } func (app *WebApp) featureMiddleware() gin.HandlerFunc { return func(c *gin.Context) { ctx := context.Background() app.appConfig.Refresh(ctx) betaEnabled, _ := app.featureManager.IsEnabled("Beta") c.Set("betaEnabled", betaEnabled) c.Next() } } func (app *WebApp) homeHandler(c *gin.Context) { c.HTML(http.StatusOK, "index.html", gin.H{ "betaEnabled": c.GetBool("betaEnabled"), }) } func (app *WebApp) betaHandler(c *gin.Context) { if !c.GetBool("betaEnabled") { c.HTML(http.StatusNotFound, "404.html", nil) return } c.HTML(http.StatusOK, "beta.html", nil) } ``` -------------------------------- ### Get Variant Value in C# Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/Microsoft.Featuremanagement.md Retrieve a variant's configuration value for a feature. Ensure the feature manager is properly configured before use. ```csharp // // Modify view based off multiple possible variants Variant variant = await featureManager.GetVariantAsync(MyFeatureFlags.BackgroundUrl); model.BackgroundUrl = variant.Configuration.Value; return View(model); ``` -------------------------------- ### Connect to App Configuration with Connection Strings Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md This API, introduced in version 6.0.0, enables connecting to App Configuration stores and their replicas using an ordered list of connection strings. ```csharp public AzureAppConfigurationOptions Connect(IEnumerable connectionStrings) ``` -------------------------------- ### Get App Configuration Endpoint Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md This property allows users to disambiguate between multiple Azure App Configuration provider instances by returning the endpoint URI of the provider. ```csharp Uri AppConfigurationEndpoint { get; } ``` -------------------------------- ### Set App Configuration Endpoint Environment Variable Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/python-django-webapp-sample/README.md Configure your application to connect to your App Configuration store by setting the AZURE_APPCONFIG_ENDPOINT environment variable. Examples for different operating systems are provided. ```command line setx AZURE_APPCONFIG_ENDPOINT "your-store-endpoint" ``` ```Powershell $Env:AZURE_APPCONFIG_ENDPOINT="your-store-endpoint" ``` ```Bash export AZURE_APPCONFIG_ENDPOINT="your-store-enpoint" ``` -------------------------------- ### Create Azure App Configuration Store Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/python-django-webapp-sample/README.md Use Azure CLI to create a new App Configuration store. Replace placeholders with your desired name and resource group. ```Powershell az appconfig create --name --resource-group --location eastus ``` -------------------------------- ### Get Variant Feature Flag Async Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/Microsoft.Featuremanagement.md Use IVariantFeatureManager to retrieve the configuration for a specific variant feature flag. Ensure you are using version 8.0.0 or above for Microsoft.Extensions.Configuration.AzureAppConfiguration or Microsoft.Azure.AppConfiguration.AspNetCore when reading from App Configuration. ```C# IVariantFeatureManager featureManager; ... Variant variant = await featureManager.GetVariantAsync(MyFeatureFlags.HelpText, CancellationToken.None); model.Text = variant.Configuration.Value; ``` -------------------------------- ### Azure App Configuration SDKs Overview Source: https://github.com/azure/appconfiguration/blob/main/README.md This section provides an overview of the SDKs available for Azure App Configuration. Each SDK supports programmatic management of key-values, feature flags, and Key Vault references. ```markdown Module | Platform | Sample | Release Notes ------ | -------- | ------ | ------------- [Azure.Data.AppConfiguration](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/appconfiguration/Azure.Data.AppConfiguration)
[![NuGet](https://img.shields.io/nuget/v/Azure.Data.AppConfiguration.svg?color=blue)](https://www.nuget.org/packages/Azure.Data.AppConfiguration/) | .NET Standard| [Sample](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/appconfiguration/Azure.Data.AppConfiguration/samples) | [Release Notes](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/appconfiguration/Azure.Data.AppConfiguration/CHANGELOG.md) [azure-data-appconfiguration](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-data-appconfiguration)
[![Maven Central](https://img.shields.io/maven-central/v/com.azure/azure-data-appconfiguration.svg?color=blue)](https://search.maven.org/artifact/com.azure/azure-data-appconfiguration) | Java | [Sample](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-data-appconfiguration/src/samples) | [Release Notes](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md) [azure/app-configuration](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/appconfiguration/app-configuration)
[![npm](https://img.shields.io/npm/v/@azure/app-configuration.svg?color=blue)](https://www.npmjs.com/package/@azure/app-configuration) | JavaScript | [Sample](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/appconfiguration/app-configuration/samples) | [Release Notes](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appconfiguration/app-configuration/CHANGELOG.md) [azure-appconfiguration](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration)
[![pypi](https://img.shields.io/pypi/v/azure-appconfiguration.svg?color=blue)](https://pypi.org/project/azure-appconfiguration/) | Python | [Sample](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration/samples) | [Release Notes](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md) [azappconfig](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/data/azappconfig)
[![Go](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig?status.svg)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig) | Go | [Sample](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/azappconfig/examples_test.go) | [Release Notes](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/data/azappconfig/CHANGELOG.md) ``` -------------------------------- ### Parse Push Notification from Event Grid Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Use this to parse a push notification from an Event Grid event. Ensure the received event is converted to an EventGridEvent object if necessary, for example, when using Service Bus. ```csharp EventGridEventExtensions.TryCreatePushNotification(this EventGridEvent eventGridEvent, out PushNotification pushNotification) ``` ```csharp IConfigurationRefresher.ProcessPushNotification(PushNotification pushNotification, TimeSpan? maxDelay = null) ``` ```csharp serviceBusClient.RegisterMessageHandler( handler: (message, cancellationToken) => { EventGridEvent eventGridEvent = EventGridEvent.Parse(BinaryData.FromBytes(message.Body)); if (eventGridEvent.TryCreatePushNotification(out PushNotification pushNotification)) { _refresher.ProcessPushNotification(pushNotification, maxDelay); } return Task.CompletedTask; }, exceptionReceivedHandler: (exceptionargs) => { Console.WriteLine($"{exceptionargs.Exception}"); return Task.CompletedTask; }); ``` -------------------------------- ### Event Grid Push Notification Handling Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md This section details how to handle push notifications from Event Grid to ensure the latest key-values are used. It includes code examples for parsing Event Grid events and processing push notifications. ```APIDOC ## Event Grid Push Notification Handling ### Description This section details how to handle push notifications from Event Grid to ensure the latest key-values are used. It includes code examples for parsing Event Grid events and processing push notifications. ### APIs Introduced * `EventGridEventExtensions.TryCreatePushNotification(this EventGridEvent eventGridEvent, out PushNotification pushNotification)` * `IConfigurationRefresher.ProcessPushNotification(PushNotification pushNotification, TimeSpan? maxDelay = null)` ### Usage Example ```csharp serviceBusClient.RegisterMessageHandler( handler: (message, cancellationToken) => { EventGridEvent eventGridEvent = EventGridEvent.Parse(BinaryData.FromBytes(message.Body)); if (eventGridEvent.TryCreatePushNotification(out PushNotification pushNotification)) { _refresher.ProcessPushNotification(pushNotification, maxDelay); } return Task.CompletedTask; }, exceptionReceivedHandler: (exceptionargs) => { Console.WriteLine($"{exceptionargs.Exception}"); return Task.CompletedTask; }); ``` ### Notes * The `sync-token` ensures that users get the latest key-values from App Configuration on any subsequent request. * After processing the push notification, the next call to `RefreshAsync()` or `TryRefreshAsync()` will retrieve the latest key-values. ``` -------------------------------- ### App Configuration Store Name (Before) Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/SpringCloudAzureAppConfigurationConfig.md This is the previous format for specifying the App Configuration store name. ```properties spring.cloud.azure.appconfiguration.stores[0].name={my-configstore-name} ``` -------------------------------- ### Connect to Azure Front Door with Default Key-Values Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Configure your application to connect to Azure Front Door and load all default key-values. Ensure your Azure Front Door filters are set to 'Key All' with a value of '*' and '(No label)'. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Load Azure App Configuration with Dynamic Refresh in Go Source: https://context7.com/azure/appconfiguration/llms.txt This Go code snippet shows how to initialize the Azure App Configuration provider, set up selectors, trim key prefixes, and enable automatic refresh with a specified interval. It requires the AZURE_APPCONFIG_CONNECTION_STRING environment variable to be set. ```go package main import ( "context" "fmt" "log" "os" "os/signal" "syscall" "time" "github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration" ) type Config struct { Font Font Message string } type Font struct { Color string Size int } func main() { configProvider, err := loadAzureAppConfiguration() if err != nil { log.Fatalf("Error loading configuration: %s", err) } // Parse configuration into struct var config Config err = configProvider.Unmarshal(&config, nil) if err != nil { log.Fatalf("Error unmarshalling configuration: %s", err) } displayConfig(config) // Register callback for configuration refresh configProvider.OnRefreshSuccess(func() { fmt.Println("\nConfiguration changed! Updating values...") var updatedConfig Config if err := configProvider.Unmarshal(&updatedConfig, nil); err != nil { log.Printf("Error unmarshalling: %s", err) return } config = updatedConfig displayConfig(config) }) done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() for { select { case <-ticker.C: go func() { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if err := configProvider.Refresh(ctx); err != nil { log.Printf("Error refreshing: %s", err) } }() case <-done: return } } } func loadAzureAppConfiguration() (*azureappconfiguration.AzureAppConfiguration, error) { connectionString := os.Getenv("AZURE_APPCONFIG_CONNECTION_STRING") options := &azureappconfiguration.Options{ Selectors: []azureappconfiguration.Selector{ {KeyFilter: "Config.*"}, }, TrimKeyPrefixes: []string{"Config."}, RefreshOptions: azureappconfiguration.KeyValueRefreshOptions{ Enabled: true, Interval: 10 * time.Second, }, } authOptions := azureappconfiguration.AuthenticationOptions{ ConnectionString: connectionString, } ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() return azureappconfiguration.Load(ctx, authOptions, options) } func displayConfig(config Config) { fmt.Println("\nCurrent Configuration:") fmt.Printf("Font Color: %s\n", config.Font.Color) fmt.Printf("Font Size: %d\n", config.Font.Size) fmt.Printf("Message: %s\n", config.Message) } ``` -------------------------------- ### Sample Chat Interaction Output Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/ChatAgent/README.md This output shows a sample interaction with the AI agent, including user input and the agent's response with weather information. ```text How can I help? (type 'quit' to exit) User: What is the weather in Seattle today ? Agent response: Seattle weather for today (Thursday, April 9, 2026): - Current conditions (as of ~10:48 AM PDT): 55°F, sunny. Wind N 6 mph (gusts 7), humidity 55%, pressure 30.05 in. ([wunderground.com](https://www.wunderground.com/weather/us/wa/seattle)) - Today’s forecast: Mostly sunny and mild. High around 64–65°F; tonight’s low near 43–44°F. Very low chance of precipitation and light winds. ([wunderground.com](https://www.wunderground.com/weather/us/wa/seattle)) Want the hour‑by‑hour forecast or weekend outlook? Press enter to continue... ``` -------------------------------- ### Define Tenant Settings Class Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/MultiTenantApplicationSetup/README.md Define a class to hold tenant-specific settings like Name and Color. This class will be dynamically populated from configuration. ```csharp // // Tenant info // public class TenantSettings { public string Name { get; set; } public string Color { get; set; } } ``` -------------------------------- ### Configure Tenant Settings Dynamically Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/MultiTenantApplicationSetup/README.md Implement IConfigureOptions to dynamically configure TenantSettings based on request headers. It retrieves the tenant ID from the 'X-Tenant-Id' header and binds the corresponding configuration section to the options. ```csharp // // Dynamically configure TenantSettings // public class ConfigureTenantSettings : IConfigureOptions { private readonly IConfiguration _configuration; private readonly IHttpContextAccessor _httpContextAccessor; public ConfigureTenantSettings( IConfiguration configuration, IHttpContextAccessor httpContextAccessor) { _configuration = configuration; _httpContextAccessor = httpContextAccessor; } public void Configure(TenantSettings options) { // // Get tenant id from the request // ex. Read tenant from a request header if (!_httpContextAccessor.HttpContext.Request.Headers.TryGetValue( "X-Tenant-Id", out StringValues tenantId)) { return; } // // Initialize from config section by TenantId _configuration.GetSection(tenantId).Bind(options); } } ``` -------------------------------- ### Configure Startup Options for Azure App Configuration Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Customize the startup retry behavior for Azure App Configuration. By default, a 100-second timeout is used, but this can be adjusted using the `ConfigureStartupOptions` API. ```csharp public AzureAppConfigurationOptions ConfigureStartupOptions(Action configure) ``` -------------------------------- ### Set App Configuration Connection String Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ConsoleApp/README.md Sets the Azure App Configuration store connection string as an environment variable. Replace 'your-connection-string' with your actual connection string. ```bash # Windows set AZURE_APPCONFIG_CONNECTION_STRING=your-connection-string ``` ```bash # Linux/macOS export AZURE_APPCONFIG_CONNECTION_STRING=your-connection-string ``` -------------------------------- ### Connect to Azure Front Door with Default Feature Flags Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Configure your application to connect to Azure Front Door and load default feature flags. Ensure your Azure Front Door filters include 'Key value' set to 'Key All' with '*' and '(No label)', and 'Feature flag' set to 'Key All' with '*' and '(No label)'. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .UseFeatureFlags(ffOptions => { ffOptions.SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Run Console Application Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/ConsoleAppWithTableStorageReference/README.md Execute the .NET console application from the terminal. Ensure you are in the application directory. ```bash dotnet run ``` -------------------------------- ### Targeting Filter with Deny List Configuration Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/SpringCloudAzureFeatureManagement.md This YAML configuration demonstrates how to use the Microsoft.Targeting filter with both inclusion and exclusion (deny list) for users and groups. It specifies rollout percentages for different groups and a default rollout percentage. ```yaml feature-management: TargetingTest: enabled-for: - name: Microsoft.Targeting parameters: users: - Jeff - Alicia groups: - name: Ring0 rolloutPercentage: 100 - name: Ring1 rolloutPercentage: 100 defaultRolloutPercentage: 50 exclusion: users: - Ross ``` -------------------------------- ### Configure Azure OpenAI Chat App with Dynamic Settings Source: https://context7.com/azure/appconfiguration/llms.txt This C# code snippet demonstrates how to load AI configuration from Azure App Configuration, including dynamic prompts and parameters. It sets up a chat client and continuously refreshes configuration to adapt to changes. ```csharp using Azure.AI.OpenAI; using Azure.Identity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.AzureAppConfiguration; using OpenAI.Chat; TokenCredential credential = new DefaultAzureCredential(); IConfigurationRefresher refresher = null; // Load AI configuration from Azure App Configuration IConfiguration configuration = new ConfigurationBuilder() .AddAzureAppConfiguration(options => { Uri endpoint = new(Environment.GetEnvironmentVariable("AZURE_APPCONFIGURATION_ENDPOINT")); options.Connect(endpoint, credential) .Select("ChatApp:*") .ConfigureRefresh(refreshOptions => refreshOptions.RegisterAll()) .ConfigureKeyVault(kv => kv.SetCredential(credential)); refresher = options.GetRefresher(); }) .Build(); // Get Azure OpenAI configuration var azureOpenAIConfig = configuration.GetSection("ChatApp:AzureOpenAI").Get(); // Create chat client AzureOpenAIClient azureClient = string.IsNullOrEmpty(azureOpenAIConfig.ApiKey) ? new AzureOpenAIClient(new Uri(azureOpenAIConfig.Endpoint), credential) : new AzureOpenAIClient(new Uri(azureOpenAIConfig.Endpoint), new Azure.AzureKeyCredential(azureOpenAIConfig.ApiKey)); ChatClient chatClient = azureClient.GetChatClient(azureOpenAIConfig.DeploymentName); var chatConversation = new List(); while (true) { // Refresh to get latest AI configuration (prompts, temperature, etc.) await refresher.TryRefreshAsync(); var chatConfig = configuration.GetSection("ChatApp:ChatCompletion").Get(); var requestOptions = new ChatCompletionOptions() { MaxOutputTokenCount = chatConfig.MaxTokens, Temperature = chatConfig.Temperature, TopP = chatConfig.TopP }; Console.Write("You: "); string userInput = Console.ReadLine(); if (string.IsNullOrEmpty(userInput)) break; chatConversation.Add(ChatMessage.CreateUserMessage(userInput)); var response = await chatClient.CompleteChatAsync(chatConversation, requestOptions); string aiResponse = response.Value.Content[0].Text; Console.WriteLine($"AI: {aiResponse}"); chatConversation.Add(ChatMessage.CreateAssistantMessage(aiResponse)); } ``` -------------------------------- ### Configure Key Vault Client Options in C# Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Use this API within `AzureAppConfigurationOptions.ConfigureKeyVault` to configure options for connecting to Key Vault resources when no SecretClient is registered. This allows for custom client configurations. ```csharp public AzureAppConfigurationKeyVaultOptions ConfigureClientOptions(Action configure) ``` -------------------------------- ### Add Azure App Configuration Provider Dependency Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/ConsoleApp/README.md Adds the Azure App Configuration provider as a dependency to your Go project. This is required to use the library. ```bash go get github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration ``` -------------------------------- ### Add Azure App Configuration Services to DI Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Use this extension method to register the necessary services for Azure App Configuration with the dependency injection container. This is a prerequisite for retrieving IConfigurationRefresher instances. ```csharp public static IServiceCollection AddAzureAppConfiguration(this IServiceCollection services) ``` -------------------------------- ### Import Key-Values from JSON using Azure CLI Source: https://context7.com/azure/appconfiguration/llms.txt Imports key-values from a local JSON file into an Azure App Configuration store using the 'kvset' profile. The JSON file must adhere to the KVSet schema. ```bash # Import key-values from JSON file using kvset profile az appconfig kv import \ --name MyAppConfigStore \ --source file \ --path ./config-import.json \ --format json \ --profile appconfig/kvset ``` -------------------------------- ### Select Snapshot for Azure App Configuration Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Specify a snapshot to load configuration from. This method is used to select a specific point-in-time configuration. ```csharp public AzureAppConfigurationOptions SelectSnapshot(string name) ``` -------------------------------- ### Connect to App Configuration Endpoints with Token Credential Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md This API, introduced in version 6.0.0, allows connecting to App Configuration endpoints using a list of URIs and a TokenCredential. It was first previewed in 5.3.0-preview. ```csharp public AzureAppConfigurationOptions Connect(IEnumerable endpoints, TokenCredential credential) ``` -------------------------------- ### Configure Azure App Configuration Settings Source: https://github.com/azure/appconfiguration/blob/main/examples/Python/ChatApp/README.md Sets up key-value pairs in your Azure App Configuration store. These settings control the chat application's behavior and AI model parameters. ```console ChatApp:AzureAIFoundry:Endpoint - Your Azure AI Foundry project endpoint URL ChatApp:ChatCompletion - An AI configuration entry containing the following settings: - model - Model name (e.g., "gpt-5") - messages - An array of messages with role and content for each message ChatApp:Sentinel - A sentinel key to trigger configuration refreshes ``` -------------------------------- ### Load Multiple Key-Value Selectors with Azure Front Door Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md This configuration loads multiple sets of key-values from Azure App Configuration using different selectors when connected via Azure Front Door. It also sets up a refresh interval for the loaded configuration. ```cs builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*") .Select("Global*", "App1Label") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Use Tenant Settings in Controller Source: https://github.com/azure/appconfiguration/blob/main/examples/DotNetCore/MultiTenantApplicationSetup/README.md Inject IOptionsSnapshot into a controller to access tenant-specific settings. The .Value property provides the current tenant's settings. ```csharp public class MyController : Controller { private readonly IOptionsSnapshot _tenantSettings; public MyController(IOptionsSnapshot tenantSettings) { _tenantSettings = tenantSettings; } [HttpGet] public IActionResult Get() { TenantSettings tenantSettings = _tenantSettings.Value; // ... } } ``` -------------------------------- ### Configure App Configuration with Tag Filters Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md Use this code to connect to Azure App Configuration with Azure Front Door and apply tag filters. Your Azure Front Door filters must include the tag name and value to match the configuration. ```csharp builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1:*", tagFilters: new[] { "Env=Dev" }) .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Register All Key-Values for Refresh Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Enables monitoring of all selected key-values for automatic refresh. When this API is called, any change to a selected key-value will trigger a configuration reload. ```cs public AzureAppConfigurationRefreshOptions RegisterAll() ``` -------------------------------- ### Connect to App Configuration with Azure AD Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md Use this method to connect to an App Configuration store using Azure Active Directory. It supports various TokenCredential types and requires the identity to have the 'App Configuration Data Reader' role. ```csharp public AzureAppConfigurationOptions Connect(Uri endpoint, TokenCredential credential) ``` -------------------------------- ### Configure App Configuration with Reserved Characters Source: https://github.com/azure/appconfiguration/blob/main/docs/AzureFrontDoor/readme.md This code snippet demonstrates connecting to Azure App Configuration with Azure Front Door when key filters contain reserved characters. Ensure your Azure Front Door filters escape these characters appropriately. ```csharp builder.Configuration.AddAzureAppConfiguration(options => { options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}")) .Select("App1\*Prefix*") .ConfigureRefresh(refreshOptions => { refreshOptions.RegisterAll() .SetRefreshInterval(TimeSpan.FromMinutes(1)); }); }); ``` -------------------------------- ### Simplify Feature Filter Registration in .NET Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/Microsoft.Featuremanagement.md Use the simplified `AddFeatureManagement()` method instead of manually registering built-in filters like `TimeWindowFilter`. ```csharp services.AddFeatureManagement() .AddFeatureFilter(); ``` ```csharp services.AddFeatureManagement(); ``` -------------------------------- ### App Configuration Store Endpoint (After) Source: https://github.com/azure/appconfiguration/blob/main/releaseNotes/SpringCloudAzureAppConfigurationConfig.md This is the updated format for specifying the App Configuration store endpoint, replacing the previous 'name' property. ```properties spring.cloud.azure.appconfiguration.stores[0].endpoint= https://{my-configstore-name}.azconfig.io ``` -------------------------------- ### Load Azure App Configuration in Python Flask with Feature Management Source: https://context7.com/azure/appconfiguration/llms.txt Integrate Azure App Configuration with a Python Flask application, supporting Key Vault references and feature flags. Configure refresh behavior using a sentinel key and provide a callback for successful refreshes. Ensure the AZURE_APPCONFIG_ENDPOINT environment variable is set. ```python import os from flask import Flask, render_template from azure.appconfiguration.provider import load, SettingSelector, WatchKey from azure.identity import DefaultAzureCredential from featuremanagement import FeatureManager app = Flask(__name__) ENDPOINT = os.environ.get("AZURE_APPCONFIG_ENDPOINT") credential = DefaultAzureCredential() # Define selectors for specific keys selects = SettingSelector(key_filter="testapp_settings_*") selects_secret = SettingSelector(key_filter="secret_key") def callback(): """Callback when configuration refreshes successfully""" app.config.update(azure_app_config) # Load configuration from Azure App Configuration azure_app_config = load( endpoint=ENDPOINT, selects=[selects, selects_secret], credential=credential, keyvault_credential=credential, # For Key Vault references trim_prefixes=["testapp_settings_"], refresh_on=[WatchKey("sentinel")], # Refresh when sentinel key changes on_refresh_success=callback, feature_flag_enabled=True, feature_flag_refresh_enabled=True, ) feature_manager = FeatureManager(azure_app_config) app.config.update(azure_app_config) @app.route("/") def index(): # Refresh configuration from App Configuration azure_app_config.refresh() context = { "message": app.config.get("message"), "font_size": app.config.get("font_size"), "color": app.config.get("color"), "key": app.config.get("secret_key"), # Key Vault reference resolved "beta": feature_manager.is_enabled("Beta") } return render_template("index.html", **context) @app.route("/beta") def beta(): return render_template("beta.html") if __name__ == "__main__": app.run() ``` -------------------------------- ### Set Azure App Configuration Connection String (Command Prompt) Source: https://github.com/azure/appconfiguration/blob/main/examples/Go/WebApp/README.md Set the connection string for Azure App Configuration as an environment variable using the Windows Command Prompt. This variable is used by the application to authenticate with the App Configuration service. ```cmd setx AZURE_APPCONFIG_CONNECTION_STRING "your-connection-string" ``` -------------------------------- ### Configure AI Chat Responses with Azure OpenAI Source: https://github.com/azure/appconfiguration/blob/main/examples/README.md This .NET console application retrieves chat responses from Azure OpenAI. It configures chat completion using AI Configuration from Azure App Configuration for rapid prompt iteration and model parameter tuning without application restarts.