-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to perform custom transforms on App Configuration Settings. #157
Comments
This does seem like a viable approach to expose a It might be a good idea to brainstorm the posssible scenarios where users might want to use transforms. That should help decide if we want to apply these after or before the feature management and key vault adapters are applied. Also, if we expose the type directly, it is possible for a user to update the |
I see two solutions to the ordering problem of before/after the built-in adapters. An enum parameter like
Or pass a way to perform our value resolution on demand, which I think is even more flexible.
And then we run the built-in mapping again internally if necessary. |
No need to over engineer from the start with ordering complexity, etc. Let's provide simple solution, calling after the internal adapters ran. The user code has the last saying what goes into the config. |
For this issue, I plan to add the following API to the class public AzureAppConfigurationOptions Map(Func<ConfigurationSetting, ValueTask<ConfigurationSetting>> mapper); |
By the naming convection used here it should be MapAsync, no? |
This would not be an asynchronous method, only the delegate it takes would be asynchronous. |
Good point. Thanks! |
If this issue can help improve the node.js SDK's ergonomics, it would be a huge benefit to users. Thanks |
ProblemAs stated previously: Some applications may need to perform custom transforms on the configuration settings they retrieve from Azure App Configuration. An example might be if an application uses a custom defined content type and has to process the value before it is acceptable to be placed in .NET Core's Proposed SolutionTo solve this problem, we can add a new API that allows the user to pass in a function that performs custom transformations on configuration settings retrieved from Azure App Configuration. // Provides a way to transform settings retrieved from App Configuration before they are processed by the
// configuration provider.
public AzureAppConfigurationOptions Map(Func<ConfigurationSetting, ValueTask<ConfigurationSetting>> mapper) Usage ExampleHere are some sample settings in App Configuration:
Let's say we set up our configurations with a call to var builder = new ConfigurationBuilder();
builder.AddAzureAppConfiguration(options =>
{
options.Connect(connectionString)
.Map((setting) =>
{
ConfigurationSetting setting = new ConfigurationSetting(
key: setting.Key.Replace("__", ":"),
value: setting.Value,
label: setting.Label);
return new ValueTask<ConfigurationSetting>(setting);
});
}); Here would be our updated settings:
Notes
|
Some applications may need to perform custom transforms on the configuration settings they retrieve from Azure App Configuration. An example might be if an application uses a custom defined content type and has to process the value before it is acceptable to be placed in .NET Core's
IConfiguration
. This is the kind of thing that is done for Key Vault references today.This can be accomplished by exposing a new
Map
method toAzureAppConfigurationOptions
.Proposed API
Usage
The
Value
of the configuration setting is what is exposed fromIConfiguration
.CC @zhenlan @drago-draganov @abhilasharora
The text was updated successfully, but these errors were encountered: