Azure / AppConfiguration-DotnetProvider

The .NET Standard configuration provider for Azure App Configuration
https://github.com/Azure/AppConfiguration
MIT License
76 stars 32 forks source link

Add new API to reload on changes to key-values #536

Open amerjusupovic opened 3 months ago

amerjusupovic commented 3 months ago

Currently, the provider only has the AzureAppConfigurationRefreshOptions.Register method as a way to monitor individual key-values for refresh. By adding a new API, we can enable monitoring for all of the key-values to be loaded by the provider. Then, when a refresh is triggered, the provider will reload the configuration if any of the loaded key-values have changed in App Configuration. RegisterAll does not affect any key-values that are only specified in calls to Register.

Proposed API: RegisterAll

config.AddAzureAppConfiguration(options => {
     options.ConfigureRefresh(refresh =>
     {
         refresh.RegisterAll();
     });
});

In this example, since the provider selects all key-values with label null by default if no Select or SelectSnapshot statement is present, all of the key-values that have no label will be monitored when RegisterAll is called. If any of them have changed since the last refresh attempt, the configuration will be reloaded.

config.AddAzureAppConfiguration(options => {
     options.Select("TestApp*", "prod");
     options.ConfigureRefresh(refresh =>
     {
         refresh.RegisterAll();
     });
});

Now, changes to key-values that start with TestApp and have the label prod will trigger a configuration reload.