config.AddAzureAppConfiguration(options =>
{
options.ConnectWithManagedIdentity(appConfigEndpoint)
.Use("AppName:Service1:*","Production")
.WatchAndReloadAll("AppName:Service1:Trigger", "Production", watchPolingInterval)
.RemovePrefix("AppName:Service1");
});
.RemovePrefix or something similar is what I am suggesting. Basically to bind the retrieved settings without the prefix so that AzureAppConfiguration automatically overrides appsettings.json and appsettings.[Environment].json
Without this 'RemovePrefix' functionality, several changes will need to be done to support both loading from appsettings and Azure App Configuration.
This is a make or break for us.
@TheReaLee, I think this is a good suggestion. Thanks!
I am thinking of an API something like this
UsePrefix(string keyPrefix, string labelFilter)
Unlike keyFilter, anything specified as "prefix" will be stripped out automatically (it will still do the filtering). So in your example, the code will look like
config.AddAzureAppConfiguration(options => {
options.ConnectWithManagedIdentity(appConfigEndpoint)
.UsePrefix("AppName:Service1:","Production")
.WatchAndReloadAll("AppName:Service1:Trigger", "Production", watchPolingInterval);
});
After some discussion with @drago-draganov, he convinced me a dedicated API to remove the prefix is actually a better idea (@TheReaLee's original suggestion 馃憤).
Here is the proposed API
public AzureAppConfigurationOptions TrimKeyPrefix(string prefix)
@zhenlan sounds perfect! Thanks for looking into it.
When are you planning to release it?
@TheReaLee, there are a few other changes I'd like to have before we roll out another release, but this shouldn't take too long.
This feature has been added in our most recent release. The AzureAppConfigurationOptions class now exposes TrimKeyPrefix.
Release Notes: https://github.com/Azure/AppConfiguration/blob/master/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md
Most helpful comment
This feature has been added in our most recent release. The
AzureAppConfigurationOptionsclass now exposesTrimKeyPrefix.Package: https://www.nuget.org/packages/Microsoft.Extensions.Configuration.AzureAppConfiguration/1.0.0-preview-008920001-990
Release Notes: https://github.com/Azure/AppConfiguration/blob/master/releaseNotes/MicrosoftExtensionsConfigurationAzureAppConfiguration.md