.NET Core has first class support for parsing hierarchical configuration data. If you have a JSON configuration like this,
{
"rootObject": [
{
"level1": "l1v1",
"level2": "l1v2"
},
{
"level1": "l2v1",
"level2": "l2v2"
}
]
}
then you can easily target individual values with "rootObject:[0]:level1". However to store this JSON, you have to either use a File System or some kind of database. The problem with this approach is that you have to modify the entire document when you want to change a value of any field. If you are not careful, you may end up corrupting the JSON and thus breaking your system.
This is where Azure App Configuration comes in the picture. Azure App Configuration is nothing but a key-value store. We can use that to store the hierarchical values like this:
Once you inject this Azure App Configuration in your .NET Core project and call Configuration.Bind() on your strongly typed representation of the JSON configuration, you get the fully populated .NET Object without writing a single line of code!
Hope this post helps you in making a decision on where and how to store your hierarchical configuration data for .NET apps.
Comments
Post a Comment
As far as possible, please refrain from posting Anonymous comments. I would really love to know who is interested in my blog! Also check out the FAQs section for the comment policy followed on this site.