These environment things seems to work for most ppl, but I don't aggree at all with all that environmental management. Whether the runtime nor the target system knows what it is. Only you, as a developer or a deployment mechanism, knows what the target system is.
Everyone is talking about ASPNETCORE_ENVIRONMENT variable, even official documentation like here https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.0. But in fact someone has to define a system explicitly as production system for example, by setting ASPNETCORE_ENVIRONMENT manually once. Do you really want to assume and rely on it that this is already set in every environment you use? No, you can't. What if you have to deploy a console app to a batch server where no website is running? ASPNETCORE_ENVIRONMENT is not available. What if you need to deploy and run a .net core webapi without IIS, only with kestrel? No web.config and no environment variable. Do you want your admins/operation team to set this misleading variable for your console app? In this context i've seen lots of projects which have appsettings like this per project:
appsettings.json
appsettings.development.json
appsettings.test.json
appsettings.uat.json
appsettings.staging.json
appsettings.production.json
Keep in mind that by default each of these files will be published and also be deployed to the target system. At a first look it looks very easy to let the environment "decide" which config should be used. But you have configuration and also potentially credentials deployed on a system which is not intended for it.
Conclusion
I recommend appsettings.json + appsettings.release.json. First one is only for dev. Change it, play with it like you want. Last one is a VALID config ready for deployment (process). Before deployment starts, transform the config to be ready for the target system. That's it. No need to rely on settings on the target machine, no messy configs. Keep full control of your app even when servers change quickly (like scaling in general, VMs, cloud, whatever)
I appreciate constructive feedback :-)