ASP.NET Core 7 configuration get section bind method does not work with double underscore values

324 views Asked by At

I am trying to read configuration values from my appSettings.json and bind them to an object. However, I am unable to get values when the environment variables hierarchy is mentioned using double underscores (__). It works when the environment variables are mentioned in JSON hierarchy.

builder.Configuration.GetSection("Serilog").GetChildren() 

returns count = 0 with double underscore. It returns count 2 when appSettings are in json format.

Configuration with double underscore which does not work

Configuration with json format which works

Any thoughts on how to get this working with the double underscore as my docker containers are having these variables as environment variables.

0

There are 0 answers