Reputation: 188
I have a .NET 6 Web Api deployed on AKS and I'm trying to use the Dynamic configuration to reload settings from Azure App Configuration without needing to restart the Pod.
When the Pod is deployed, changes made to settings (shortly after deploying the Pod) on Azure App Configuration are picked up by my app. However, if I come the next day lets say and I update a setting on Azure App Config then this is not picked up by the Web Api. The same happens for Feature Flags updates.
Code and setup: Azure App Config
Program.cs
builder.Host.ConfigureAppConfiguration(config =>
{
config.AddAzureAppConfiguration(option =>
option.Connect(appConfigConnString)
.ConfigureRefresh(refreshOptions =>
{
refreshOptions.Register("AppSettings:TestReloadTesting", refreshAll: true);
refreshOptions.SetCacheExpiration(TimeSpan.FromSeconds(5));
})
.ConfigureKeyVault(kv => kv.SetCredential(new DefaultAzureCredential(defaultAzureCredentialOptions)))
.UseFeatureFlags(options =>
{
options.Label = "Feature-flag-label";
options.CacheExpirationInterval = TimeSpan.FromSeconds(5);
})
);
});
builder.Services.AddAzureAppConfiguration();
builder.Services.AddFeatureManagement(builder.Configuration.GetSection("FeatureManagement"));
...........
var app = builder.Build();
app.UseAzureAppConfiguration();
app.UseFeatureAvailability();
...........
Controller actions that reads the config settings and Feature flags
[HttpGet("TestAppSetting")]
public ActionResult<Result> GetTestAppSettingReload()
{
var result = _appsettings.TestReloadTesting;
return new Result{ TestReloadTesting = result };
}
[HttpGet("TestFeature")]
public async Task<ActionResult<string>> GetTestFearureFlag()
{
var result = await _featureManager.IsEnabledAsync("feature-name");
return Ok(result);
}
I don't get any errors whatsoever and I have looked at the documentation but haven't found anything related to that.
Upvotes: 0
Views: 186
Reputation: 1533
Please note that the configuration refresh happens asynchronously to the processing of your app's incoming requests. It will not block or slow down the incoming request that triggered the refresh. The request that triggered the refresh may not get the updated configuration values, but later requests will get new configuration values.
You can find more details in Request-driven configuration refresh.
Upvotes: 0
Reputation: 21
in your code, can you do the following to see if it works:
builder.Configuration.AddAzureAppConfiguration(option =>
option.Connect(connectionString)
.ConfigureRefresh(refreshOptions =>
{
refreshOptions.Register("TestApp:Settings", refreshAll: true);
refreshOptions.SetCacheExpiration(TimeSpan.FromSeconds(5));
})
.UseFeatureFlags(options =>
{
options.Label = "Feature-flag-label";
options.CacheExpirationInterval = TimeSpan.FromSeconds(5);
}));
Upvotes: 0