question

JoelPalmer-4935 avatar image
0 Votes"
JoelPalmer-4935 asked JoelPalmerJLPM-3215 answered

Pull App Configuration values from Azure

.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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SamaraSoucy-MSFT avatar image
0 Votes"
SamaraSoucy-MSFT answered

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
     }



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JoelPalmerJLPM-3215 avatar image
0 Votes"
JoelPalmerJLPM-3215 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.