I've set up Azure App Configuration (AAC) dynamic updating for an ASP.NET 7 on-prem app. This is working fine. I'd like to be able to run some additional code whenever it updates the config though. This would only happen when the sentinel key changes and it actually updates the config locally, not whenever another key changes in AAC.
I've seen potential ways using EventGrid, but I'm wondering if there's something simpler that I can do, purely from the app side.
You could try using the Microsoft.Extensions.Configuration.AzureAppConfiguration SDK that will help you detect change from the app configuration.
First install the
Microsoft.Azure.AppConfiguration.AspNetCore
andMicrosoft.Extensions.Configuration.AzureAppConfiguration
NuGet packages.Here is the sample code:
Startup.cs:
Below ode will detect the changes:
Here is the link you can refer for push or poll model:
https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core?tabs=core6x
Another ways is using the IOptionsMonitor, it is use to retrieve options and manage options notifications for TOptions instances.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptionsmonitor-1?view=dotnet-plat-ext-7.0
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0&source=post_page-----e26b71cfdb2f--------------------------------#options-interfaces-1