ASP.NET Core › Configuration & Options Pattern
How do environment variables map to nested configuration keys, given some shells don't support colons in variable names?
IntermediateAnswer
The environment variable configuration provider uses double underscores (__) as the hierarchy separator instead of colons, since some shells and operating systems don't support colons in environment variable names -- ASP.NET Core automatically translates ConnectionStrings__DefaultConnection into the equivalent "ConnectionStrings:DefaultConnection" configuration key internally.
# Setting a nested configuration value via environment variable
export ConnectionStrings__DefaultConnection="Server=prod;Database=MyApp;"
# Equivalent to this in appsettings.json:
# { "ConnectionStrings": { "DefaultConnection": "Server=prod;Database=MyApp;" } }Real-world example A Kubernetes deployment manifest sets Logging__LogLevel__Default=Warning as a container environment variable, correctly overriding the nested Logging:LogLevel:Default key from the base appsettings.json without any code changes.