-
Notifications
You must be signed in to change notification settings - Fork 35
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 yaml support #381
Comments
Hi @carlin-q-scott , as of now we recommend using the application/json content type and converting yaml data to json format when necessary. Please let us know if you have any questions or issues you feel aren't addressed by this approach. |
The issue is having to convert back and forth between JSON and YAML. azure App Configuration is targeting administrators who enjoy simplicity. YAML is simplicity - there's a reason it's achieved nearly ubiquitous adoption. Sorry to sound snarky, but I feel like this was self-evident in the OP's request and the response seemed very dismissive. |
I never intended to be dismissive of the original question, so I'm sorry if I came across that way. From what I understand, yaml can be converted to json fairly easily so I thought it wouldn't introduce a large hurdle for anyone who wants to parse a yaml file. I wanted to know if anyone's aware of an issue with this, or a use case that I might not have considered, because then I would appreciate them bringing up any issues with my original understanding. I agree that having YAML parsing could make things a bit easier for some users. The nuget package for parsing yaml that was mentioned does mean we have to add a new dependency, which we usually try to avoid. We didn't think there was a strong enough reason to add this capability, so we recommended the approach that I mentioned. We're of course open to reconsidering this if it's something that people feel strongly about. |
@amerjusupovic You could instead make |
And here I was thinking we could do this on my project (implementing our own IKeyValueAdapters). Are there any plans for this? or any workarounds |
@amerjusupovic can this be done by user code through the Map API? |
@zhenlan I had a quick discussion with @samsadsam about this, and the only issue we discovered is that Making |
Thanks @amerjusupovic.
Will it work if we change the Map API to return enumerable of ConfigurationSetting?
Why not? It sounds like a reasonable workaround for user code to handle YAML. Even if the Map API worked, the user code would still need to deal with YAML. |
I think that's possible, that would mean you wouldn't have to convert to json, but you'd have to parse yaml and flatten it within a call to Map still.
I didn't mention Map API as part of the solution with converting to json originally, so that's a fair point. I would think it's less work to implement for users too. It still requires some work to implement a custom |
@fvidesf To clarify, the workaround is to use the It would look something like this, where using YamlDotNet.Serialization;
using System.Text.Json;
// other code
options.Map(setting =>
{
if (setting.ContentType == "application/yaml")
{
var deserializer = new DeserializerBuilder().Build();
var yamlObject = deserializer.Deserialize<object>(setting.Value);
string newSettingJsonValue = JsonSerializer.Serialize(yamlObject);
ConfigurationSetting newSetting = new ConfigurationSetting(setting.Key, newSettingJsonValue, setting.Label, setting.ETag);
newSetting.ContentType = "application/json";
return new ValueTask<ConfigurationSetting>(newSetting);
}
return new ValueTask<ConfigurationSetting>(setting);
}); |
So the suggestion is to parse and map YAML to JSON only for that JSON to be parsed yet again to key-value pairs? That seems like a very ugly hack. The better solution would be a proper public API to define the policy for mapping configuration content to configuration key/value pairs such as |
I'd like to be able to store application/yaml content in my app config keys and have this library deserialize it.
I found the json key value adaptor in src/Microsoft.Extensions.Configuration.AzureAppConfiguration/JsonKeyValueAdapter.cs. I don't think it would take much work to implement that for yaml. But it would add a dependency on another nuget package.
The text was updated successfully, but these errors were encountered: