✅ Asp .NET Core production settings.json question.
Hi all,
As you know you have an appsettings.json file.
Which contains some general things such as:
We also have a launchsettings.json file
In production when we publish our app, what is the default running environment?
How do I set the ASPNETCORE_ENVIRONMENT to "Production" in production?
How do I set a seperate ConnectionString_SqlServer for production?
Does the published production build have these .json files or do they rely solely on the HOST environment variables?
26 Replies
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
Thanks,
So if I get it correctly default with a fresh host system, no set ENV variables, it will default to production as there is none?
As for the second question in production what is the best for the appsettings.json file, also make them connectionstring_sqlserver variables or?
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
I think configuration is loaded depending on which environment is selected if development: appsettings.development.json
if production appsettings.production.json. If there are any ENV variables set with same name it will use that, if there are any usersecrets it will use that
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
I will, thankyou
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
I see thanks, I will read through the docs. Now that you mention it, I also have a default
appsettings.json
witouth a .env next to my .development.json. I am guessing that is lowes priority and that is applied to both if not overridden?Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
Sorry I meant that haha, I could've formulated it clearer 😅 .
I meant I have a appsettings.json (no .env such as .development) and a appsettings.development.json
And my question was, what is the purpose of that one witouth the .env?
It will just have the lowest priority and will get applied if nothing overrides it?
After reading the docs that is the case 😛
Thankyou for the help
Then I have one more question.
Storing a connection string that gets pushed to the github repo is not a good idea.
So what is the best way to pass it this one without giving it in appsettings.Production.json?
ENV variable, CLI argument, ... what would you do?
don't commit appsettings.Production.json to git
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
i commit appsettings.json with defaults or empty values and use user secrets in development, production values only exist on the actual production server
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
it's good practice to run the application on a service account, using integrated security to do its thing
connection strings aren't the only secrets i deal with
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
you can use integrated security as long as you're in a windows environment using sql server, sure
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
i was responding to greyfox
i don't use it either
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
There's the likes of Credentials Manager as well if it's a windows server box
i just wrote a custom json configuration provider that encrypts secrets with DPAPI
Gotcha thanks guys
We did push appsettings files
but not to worry
they don't contain sensitive data
Unknown User•3d ago
Message Not Public
Sign In & Join Server To View
I invoke the 5th 😅