Pull App Configuration values from Azure

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

.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.
186 questions
No comments
{count} votes

2 answers

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

    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  
        }  
    
    No comments

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

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

    No comments