From 0b3ac26f7888f8e35755d2972c925d0f189ef8ec Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Thu, 4 Sep 2025 12:51:39 +0800 Subject: [PATCH 1/4] add overload to take endpoint and credential --- .../AzureAppConfigurationExtensions.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs index f8c2c5caf..721bf5f19 100644 --- a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs +++ b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. // +using Azure.Core; using Microsoft.Extensions.Configuration.AzureAppConfiguration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -63,6 +64,44 @@ public static IConfigurationBuilder AddAzureAppConfiguration( return configurationBuilder.AddAzureAppConfiguration(options => options.Connect(connectionStrings), optional); } + /// + /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// + /// The configuration builder to add key-values to. + /// The endpoint used to connect to the configuration store. + /// The token credential used to authenticate requests to the configuration store. + /// Determines the behavior of the App Configuration provider when an exception occurs while loading data from server. If false, the exception is thrown. If true, the exception is suppressed and no settings are populated from Azure App Configuration. + /// will always be thrown when the caller gives an invalid input configuration (connection strings, endpoints, key/label filters...etc). + /// + /// The provided configuration builder. + public static IConfigurationBuilder AddAzureAppConfiguration( + this IConfigurationBuilder configurationBuilder, + Uri endpoint, + TokenCredential credential, + bool optional = false) + { + return configurationBuilder.AddAzureAppConfiguration(options => options.Connect(endpoint, credential), optional); + } + + /// + /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// + /// The configuration builder to add key-values to. + /// The list of endpoints used to connect to the configuration store and its replicas. + /// The token credential used to authenticate requests to the configuration store. + /// Determines the behavior of the App Configuration provider when an exception occurs while loading data from server. If false, the exception is thrown. If true, the exception is suppressed and no settings are populated from Azure App Configuration. + /// will always be thrown when the caller gives an invalid input configuration (connection strings, endpoints, key/label filters...etc). + /// + /// The provided configuration builder. + public static IConfigurationBuilder AddAzureAppConfiguration( + this IConfigurationBuilder configurationBuilder, + IEnumerable endpoints, + TokenCredential credential, + bool optional = false) + { + return configurationBuilder.AddAzureAppConfiguration(options => options.Connect(endpoints, credential), optional); + } + /// /// Adds key-value data from an Azure App Configuration store to a configuration builder. /// From 7f0df98001d9caa0079085544039b52006d04872 Mon Sep 17 00:00:00 2001 From: zhiyuanliang Date: Sun, 7 Sep 2025 01:05:33 +0800 Subject: [PATCH 2/4] enrich comment for intellisense --- .../AzureAppConfigurationExtensions.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs index 721bf5f19..9dc4b0bad 100644 --- a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs +++ b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs @@ -31,7 +31,7 @@ private static bool IsProviderDisabled() } /// - /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// Adds key-value data from an Azure App Configuration store to a configuration builder using its connection string. /// /// The configuration builder to add key-values to. /// The connection string used to connect to the configuration store. @@ -48,7 +48,7 @@ public static IConfigurationBuilder AddAzureAppConfiguration( } /// - /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// Adds key-value data from a primary Azure App Configuration store and one or more replica stores to a configuration builder using connection strings. /// /// The configuration builder to add key-values to. /// The list of connection strings used to connect to the configuration store and its replicas. @@ -65,7 +65,7 @@ public static IConfigurationBuilder AddAzureAppConfiguration( } /// - /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// Adds key-value data from an Azure App Configuration store to a configuration builder using endpoint with AAD authentication. /// /// The configuration builder to add key-values to. /// The endpoint used to connect to the configuration store. @@ -84,7 +84,7 @@ public static IConfigurationBuilder AddAzureAppConfiguration( } /// - /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// Adds key-value data from a primary Azure App Configuration store and one or more replica stores to a configuration builder using endpoints with AAD authentication. /// /// The configuration builder to add key-values to. /// The list of endpoints used to connect to the configuration store and its replicas. @@ -103,7 +103,8 @@ public static IConfigurationBuilder AddAzureAppConfiguration( } /// - /// Adds key-value data from an Azure App Configuration store to a configuration builder. + /// Adds key-value data from an Azure App Configuration store to a configuration builder using a fully configurable callback for advanced scenarios. + /// Use this overload when you need to: select keys by prefix, filter by labels, configure dynamic refresh, use feature flags, resolve Key Vault references, etc. /// /// The configuration builder to add key-values to. /// A callback used to configure Azure App Configuration options. From fe215f58d1d34c66baa0314616de620faec89494 Mon Sep 17 00:00:00 2001 From: Zhiyuan Liang Date: Wed, 17 Sep 2025 16:27:17 +0800 Subject: [PATCH 3/4] update comment to point to use options.connect pattern --- .../AzureAppConfigurationExtensions.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs index 9dc4b0bad..862d15ec3 100644 --- a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs +++ b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs @@ -32,6 +32,9 @@ private static bool IsProviderDisabled() /// /// Adds key-value data from an Azure App Configuration store to a configuration builder using its connection string. + /// This is a simplified overload that loads all key-values with no label. For advanced scenarios such as selecting specific keys, + /// filtering by labels, configuring refresh, using feature flags, or resolving Key Vault references, + /// use the overload that accepts an parameter with options.Connect(). /// /// The configuration builder to add key-values to. /// The connection string used to connect to the configuration store. @@ -49,6 +52,9 @@ public static IConfigurationBuilder AddAzureAppConfiguration( /// /// Adds key-value data from a primary Azure App Configuration store and one or more replica stores to a configuration builder using connection strings. + /// This is a simplified overload that loads all key-values with no label. For advanced scenarios such as selecting specific keys, + /// filtering by labels, configuring refresh, using feature flags, or resolving Key Vault references, + /// use the overload that accepts an parameter with options.Connect(). /// /// The configuration builder to add key-values to. /// The list of connection strings used to connect to the configuration store and its replicas. @@ -66,6 +72,9 @@ public static IConfigurationBuilder AddAzureAppConfiguration( /// /// Adds key-value data from an Azure App Configuration store to a configuration builder using endpoint with AAD authentication. + /// This is a simplified overload that loads all key-values with no label. For advanced scenarios such as selecting specific keys, + /// filtering by labels, configuring refresh, using feature flags, or resolving Key Vault references, + /// use the overload that accepts an parameter with options.Connect(). /// /// The configuration builder to add key-values to. /// The endpoint used to connect to the configuration store. @@ -85,6 +94,9 @@ public static IConfigurationBuilder AddAzureAppConfiguration( /// /// Adds key-value data from a primary Azure App Configuration store and one or more replica stores to a configuration builder using endpoints with AAD authentication. + /// This is a simplified overload that loads all key-values with no label. For advanced scenarios such as selecting specific keys, + /// filtering by labels, configuring refresh, using feature flags, or resolving Key Vault references, + /// use the overload that accepts an parameter with options.Connect(). /// /// The configuration builder to add key-values to. /// The list of endpoints used to connect to the configuration store and its replicas. From 1b18ea8096f1e125314e366b10dd624af3fdd3af Mon Sep 17 00:00:00 2001 From: zhiyuanliang Date: Thu, 18 Sep 2025 00:12:12 +0800 Subject: [PATCH 4/4] update --- .../AzureAppConfigurationExtensions.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs index 862d15ec3..8d1419690 100644 --- a/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs +++ b/src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs @@ -92,28 +92,6 @@ public static IConfigurationBuilder AddAzureAppConfiguration( return configurationBuilder.AddAzureAppConfiguration(options => options.Connect(endpoint, credential), optional); } - /// - /// Adds key-value data from a primary Azure App Configuration store and one or more replica stores to a configuration builder using endpoints with AAD authentication. - /// This is a simplified overload that loads all key-values with no label. For advanced scenarios such as selecting specific keys, - /// filtering by labels, configuring refresh, using feature flags, or resolving Key Vault references, - /// use the overload that accepts an parameter with options.Connect(). - /// - /// The configuration builder to add key-values to. - /// The list of endpoints used to connect to the configuration store and its replicas. - /// The token credential used to authenticate requests to the configuration store. - /// Determines the behavior of the App Configuration provider when an exception occurs while loading data from server. If false, the exception is thrown. If true, the exception is suppressed and no settings are populated from Azure App Configuration. - /// will always be thrown when the caller gives an invalid input configuration (connection strings, endpoints, key/label filters...etc). - /// - /// The provided configuration builder. - public static IConfigurationBuilder AddAzureAppConfiguration( - this IConfigurationBuilder configurationBuilder, - IEnumerable endpoints, - TokenCredential credential, - bool optional = false) - { - return configurationBuilder.AddAzureAppConfiguration(options => options.Connect(endpoints, credential), optional); - } - /// /// Adds key-value data from an Azure App Configuration store to a configuration builder using a fully configurable callback for advanced scenarios. /// Use this overload when you need to: select keys by prefix, filter by labels, configure dynamic refresh, use feature flags, resolve Key Vault references, etc.