Overriding appsettings.json section with environment variable
Given a configuration section called
Given I want this
I'm doing
I'm trying to bind it against an object with the options pattern:
And the classes look like:
When I run the ASP.NET Core app, the
For the record, I can see the whole structure if I just log
So how do you actually override a whole section with a JSON value through an environment variable?
Tenants, I'd like to override it with a whole JSON structure via an environment variable.Given I want this
I'm doing
I'm trying to bind it against an object with the options pattern:
And the classes look like:
When I run the ASP.NET Core app, the
ByCode dictionary is empty. But if I just paste the JSON section in appsettings.json, it's correctly populated.For the record, I can see the whole structure if I just log
builder.Configuration.GetSection(TenantsOptions.SectionName).Value;, but for some reason, I guess it's only interpreted as a string, and not correctly deserialized and bound to TenantOptions?So how do you actually override a whole section with a JSON value through an environment variable?
