Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redesigning Configuration Refresh for Azure App Configuration

#1
Redesigning Configuration Refresh for Azure App Configuration

Avatar

Overview


Since its inception, the .NET Core configuration provider for Azure App Configuration has provided the capability to monitor changes and sync them to the configuration within a running application. We recently redesigned this functionality to allow for on-demand refresh of the configuration. The new design paves the way for smarter applications that only refresh the configuration when necessary. As a result, inactive applications no longer have to monitor for configuration changes unnecessarily.

Initial design : Timer-based watch


In the initial design, configuration was kept in sync with Azure App Configuration using a watch mechanism which ran on a timer. At the time of initialization of the Azure App Configuration provider, users could specify the configuration settings to be updated and an optional polling interval. In case the polling interval was not specified, a default value of 30 seconds was used.

public static IWebHost BuildWebHost(string[] args)
{ WebHost.CreateDefaultBuilder(args) .ConfigureAppConfiguration((hostingContext, config) => { // Load settings from Azure App Configuration // Set up the provider to listen for changes triggered by a sentinel value var settings = config.Build(); string appConfigurationEndpoint = settings["AzureAppConfigurationEndpoint"]; config.AddAzureAppConfiguration(options => { options.ConnectWithManagedIdentity(appConfigurationEndpoint) .Use(keyFilter: "WebDemo:*") .WatchAndReloadAll(key: "WebDemo:Sentinel", label: LabelFilter.Null); }); settings = config.Build(); }) .UseStartup<Startup>() .Build();
}

For example, in the above code snippet, Azure App Configuration would be pinged every 30 seconds for changes. These calls would be made irrespective of whether the application was active or not. As a result, there would be unnecessary usage of network and CPU resources within inactive applications. Applications needed a way to trigger a refresh of the configuration on demand in order to be able to limit the refreshes to active applications. Then unnecessary checks for changes could be avoided.

This timer-based watch mechanism had the following fundamental design flaws.

  1. It could not be invoked on-demand.
  2. It continued to run in the background even in applications that could be considered inactive.
  3. It promoted constant polling of configuration rather than a more intelligent approach of updating configuration when applications are active or need to ensure freshness.

New design : Activity-based refresh


The new refresh mechanism allows users to keep their configuration updated using a middleware to determine activity. As long as the ASP.NET Core web application continues to receive requests, the configuration settings continue to get updated with the configuration store.

The application can be configured to trigger refresh for each request by adding the Azure App Configuration middleware from package Microsoft.Azure.AppConfiguration.AspNetCore in your application’s startup code.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ app.UseAzureAppConfiguration(); app.UseMvc();
}

At the time of initialization of the configuration provider, the user can use the ConfigureRefresh method to register the configuration settings to be updated with an optional cache expiration time. In case the cache expiration time is not specified, a default value of 30 seconds is used.

public static IWebHost BuildWebHost(string[] args)
{ WebHost.CreateDefaultBuilder(args) .ConfigureAppConfiguration((hostingContext, config) => { // Load settings from Azure App Configuration // Set up the provider to listen for changes triggered by a sentinel value var settings = config.Build(); string appConfigurationEndpoint = settings["AzureAppConfigurationEndpoint"]; config.AddAzureAppConfiguration(options => { options.ConnectWithManagedIdentity(appConfigurationEndpoint) .Use(keyFilter: "WebDemo:*") .ConfigureRefresh((refreshOptions) => { // Indicates that all settings should be refreshed when the given key has changed refreshOptions.Register(key: "WebDemo:Sentinel", label: LabelFilter.Null, refreshAll: true); }); }); settings = config.Build(); }) .UseStartup<Startup>() .Build();
}

In order to keep the settings updated and avoid unnecessary calls to the configuration store, an internal cache is used for each setting. Until the cached value of a setting has expired, the refresh operation does not update the value. This happens even when the value has changed in the configuration store.

Try it now!


For more information about Azure App Configuration, check out the following resources. You can find step-by-step tutorials that would help you get started with dynamic configuration using the new refresh mechanism within minutes. Please let us know what you think by filing issues on GitHub.

Overview: Azure App configuration
Tutorial: Use dynamic configuration in an ASP.NET Core app
Tutorial: Use dynamic configuration in a .NET Core app
Related Blog: Configuring a Server-side Blazor app with Azure App Configuration

Avatar

Software Engineer, Azure App Configuration

Follow    



https://www.sickgaming.net/blog/2019/08/...iguration/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  App Building with Azure API Management, Functions, Power Apps, and Logic Apps xSicKxBot 0 48 02-25-2021, 05:19 AM
Last Post: xSicKxBot
  Azure Static Web Apps with .NET and Blazor xSicKxBot 0 206 09-23-2020, 07:22 PM
Last Post: xSicKxBot
  Configuring Azure Services and emulators using Visual Studio xSicKxBot 0 233 06-04-2020, 12:16 PM
Last Post: xSicKxBot
  Configuring Azure Services and emulators using Visual Studio xSicKxBot 0 272 05-08-2020, 02:41 AM
Last Post: xSicKxBot
  Azure SignalR Service now supports Event Grid! xSicKxBot 0 402 10-20-2019, 11:14 PM
Last Post: xSicKxBot
  Redesigning Configuration Refresh for Azure App Configuration xSicKxBot 0 549 09-10-2019, 11:14 PM
Last Post: xSicKxBot
  Azure SignalR Service now supports Event Grid! xSicKxBot 0 437 09-10-2019, 10:38 AM
Last Post: xSicKxBot
  Configuring a Server-side Blazor app with Azure App Configuration xSicKxBot 0 605 09-09-2019, 03:07 PM
Last Post: xSicKxBot
  What’s new in Azure SignalR 1.1.0 Preview 1 xSicKxBot 0 434 09-08-2019, 05:47 PM
Last Post: xSicKxBot
  Configuring a Server-side Blazor app with Azure App Configuration xSicKxBot 0 547 07-26-2019, 12:21 AM
Last Post: xSicKxBot

Forum Jump:

[-]
Active Threads
[Tut] Private and Public Attributes in P...
Last Post: xSicKxBot
Yesterday 11:05 PM
» Replies: 0
» Views: 3
(Indie Deal) Adventure Tales Bundle, Qua...
Last Post: xSicKxBot
Yesterday 11:05 PM
» Replies: 0
» Views: 4
Mobile - Arena battler Smash Legends goe...
Last Post: xSicKxBot
Yesterday 11:05 PM
» Replies: 0
» Views: 3
News - Epic Secures $1 Billion In Fundin...
Last Post: xSicKxBot
Yesterday 11:04 PM
» Replies: 0
» Views: 3
News - Anniversary: The Animal Crossing ...
Last Post: xSicKxBot
Yesterday 11:04 PM
» Replies: 0
» Views: 3
News - TMNT: Shredder's Revenge Confirme...
Last Post: xSicKxBot
Yesterday 11:04 PM
» Replies: 0
» Views: 5
Unigine 2.14 Released
Last Post: xSicKxBot
Yesterday 03:06 PM
» Replies: 0
» Views: 8
News - Lawson Will Offer New Pokémon Sna...
Last Post: xSicKxBot
Yesterday 03:06 PM
» Replies: 0
» Views: 7
News - Nacon Announces WRC 10, Speeds On...
Last Post: xSicKxBot
Yesterday 03:06 PM
» Replies: 0
» Views: 5
News - Blizzard Arcade Collection Gets T...
Last Post: xSicKxBot
Yesterday 03:06 PM
» Replies: 0
» Views: 15

[-]
Twitter

[-]
Sponsored
Get the Deal of the Week at RefurBees.com

Copyright © SickGaming.net 2012-2020