ASP.NET Core configuration system: Isn’t the default configuration prone to naming conflicts in environment variables?
I’m trying to wrap my head around the ASP.NET Core Configuration system.
If I understand the default configuration correctly, non-prefixed environment variables will override appsettings.json entries.
For example, if
-
I have an appSettings.json file like this
{ "SmtpServer": "myserver.example.com" } -
and some other, completely unrelated application running on the same server happens to (globally) set an environment variable called
SmtpServertosomeotherserver.example.com
that environment variable will override my application configuration.
Now, obviously, I could work around this by (1) prefixing all my settings with the name of my app (which will create a lot of noise in my appsettings.json) or (2) use my own WebApplicationBuilder (2a) to override to default priority order or (2b) to only include environment variables with a specific prefix or (3) blame the other application for setting a global environment variable with such a generic name.
Still, the ASP.NET Core designers are smart people, and if they implement default values, they usually have a very good reason for doing so.
What am I missing? Did I find a flaw in the ASP.NET Core Configuration system default configuration [sic, no pun intended], or is this, for some reason, not a problem in real-life systems? If the latter, what is that reason?
