Stop Restarting Your Apps: Dynamic Azure App Configuration
Centralizing your app settings is smart. Restarting your live APIs just to tweak a feature flag is not.
Azure App Configuration solves this. It lets you change settings on the fly. No downtime. No deployment pipeline. Just instant updates.
But you have to do it right. The Standard tier limits your free requests. If a dozen microservices aggressively poll your entire config tree, you will burn through your quota and hit throttling limits fast.
Here are the two ways to handle dynamic refreshes efficiently.
1. The Sentinel Pattern (Pull)
Stop polling everything. Poll one thing.
Create a single dummy key in Azure App Configuration called the "Sentinel". Your app only checks this one key on a timer. When you update your real settings, you update the Sentinel last. The app notices the Sentinel changed and instantly reloads the rest of the configuration tree.
builder.Configuration.AddAzureAppConfiguration(options =>
{
options.Connect(builder.Configuration["AppConfigConnectionString"])
.ConfigureRefresh(refresh =>
{
refresh.Register("Sentinel", refreshAll: true)
.SetCacheExpiration(TimeSpan.FromMinutes(5));
});
});
builder.Services.AddAzureAppConfiguration();
var app = builder.Build();
app.UseAzureAppConfiguration();
2. Event Grid (Push)
Don't want to wait for a polling timer? Push the changes.
App Configuration integrates with Azure Event Grid. When you modify a key, Event Grid fires a webhook to your API. Your API catches the event and tells its internal config provider to mark its cache as dirty. The next time a request comes in, it fetches the fresh data.
[HttpPost("api/config/refresh")]
public IActionResult RefreshConfig([FromServices] IConfigurationRefresherProvider refresherProvider)
{
foreach (var refresher in refresherProvider.Refreshers)
{
refresher.SetDirty(TimeSpan.FromSeconds(1));
}
return Ok();
}
