Pull App Configuration values from Azure

Joel Palmer 1 Reputation point
2021-03-23T19:28:34.637+00:00

.NET 5 Core applications pulls App Configuration values from Azure by the following call in the Program.cs file.

                    webBuilder.ConfigureAppConfiguration((context, config) =>
                    {
                        var builtConfig = config.Build();

                        config.AddAzureAppConfiguration(options =>
                        {
                            options.Connect(builtConfig["AppConfigEndpoint"])
                                .ConfigureKeyVault(kv =>
                                {
                                    kv.SetCredential(new DefaultAzureCredential());
                                })
                                .Select(KeyFilter.Any, LabelFilter.Null)
#if DEBUG
                                .Select(KeyFilter.Any, "Debug");
#else
                                .Select(KeyFilter.Any, "Deployed");
#endif
                        });
                    });

I need to pull these values into a WPF application. How?

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
205 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,051 Reputation points
    2021-03-25T03:29:15.797+00:00

    It's very similar in other .NET development projects, but you will be calling ConfigurationBuilder instead of the web config builder:

    private static IConfiguration _configuration = null;  
        private static IConfigurationRefresher _refresher = null;  
      
        static void Main(string[] args)  
        {  
            var builder = new ConfigurationBuilder();  
            builder.AddAzureAppConfiguration(options =>  
            {  
                options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))  
                        .ConfigureRefresh(refresh =>  
                        {  
                            refresh.Register("TestApp:Settings:Message")  
                                   .SetCacheExpiration(TimeSpan.FromSeconds(10));  
                        });  
                          
                        _refresher = options.GetRefresher();  
            });  
      
            _configuration = builder.Build();  
      
            //continue on with your startup  
        }  
    
    0 comments No comments

  2. Joel Palmer (JLPM) 141 Reputation points
    2021-03-26T17:22:33.723+00:00

    Thank you for your help. This is close to what I've discovered.

    0 comments No comments