Configuring database connections for local/production
Hi,
I'm new to .NET Core and the 'deployment' side of Umbraco 10. I'd like to deploy an Umbraco 10 site to a client VM. I've created a publish profile (FTP version as that's all the host server supports) and deployed the files up without any issues. However, I need to update the db connection string. I gather this should be done by using an environment-specific appsettings.json file for production, but I'm struggling to find any explanations/documentation on exactly how to do this without a good previous understanding of environment variables etc.
At the moment I have a relatively 'vanilla' Umbraco instance, so it comes with a properties/launchSettings.json file, populated with the following:
Do I need to add a 'production' or 'release'(?) setting in there? If so, is there an example as it's not obvious to me which parts to replicate and what things should be called?
Then how about appsettings.{environment}.json? Should I create a production or release version of that? (Which?) If so, does anyone have an example of what it should contain in order to override the local connection setting with a production one?
If anyone could shed any light on this it would be much appreciated. I'm sure it's easy when you know how! 😅
Thanks Huw. The stuff about Papercut/SMTP? I see from that I can create a machine config for my local machine but then that's confusing in itself as I thought that's what the 'Development' config was for. It mentions adding code to Program.cs to register the machine config but no mention of adding anything into properties/launchSettings.json, which I thought was how the publish profile knew which config to use?
I've never touched launch settings myself tbh, I normally just rely on appsettings.json for my live site and appsettings.develoment locally, I just like the idea of using the machine name method as it is then pretty obvious which is getting used.
So you have two database connection settings — one in appsettings.json and another in appsettings.development.json? And it just defaults such that the dev one is used locally but when it's deployed the publish task discards that and uses appsettings.json? So effectively you haven't taken any steps to create a production/release variation, you've just stuck with appsettings.json and appsettings.development.json and it 'just works'?
That would work for me — I don't have any desire to make things any more complicated, but would like to not have to manually switch connection strings every time I deploy. Am I understanding the above correctly? Thanks - appreciate the clarification.
Configuring database connections for local/production
Hi,
I'm new to .NET Core and the 'deployment' side of Umbraco 10. I'd like to deploy an Umbraco 10 site to a client VM. I've created a publish profile (FTP version as that's all the host server supports) and deployed the files up without any issues. However, I need to update the db connection string. I gather this should be done by using an environment-specific appsettings.json file for production, but I'm struggling to find any explanations/documentation on exactly how to do this without a good previous understanding of environment variables etc.
At the moment I have a relatively 'vanilla' Umbraco instance, so it comes with a
properties/launchSettings.json
file, populated with the following:Do I need to add a 'production' or 'release'(?) setting in there? If so, is there an example as it's not obvious to me which parts to replicate and what things should be called?
Then how about appsettings.{environment}.json? Should I create a production or release version of that? (Which?) If so, does anyone have an example of what it should contain in order to override the local connection setting with a production one?
If anyone could shed any light on this it would be much appreciated. I'm sure it's easy when you know how! 😅
There is a post in the Umbraco Discord channel about this exact thing :)
https://discord.com/channels/869656431308189746/882984410432012360/1082655949287850017
May be worth joining and taking a look.
Thanks Huw. The stuff about Papercut/SMTP? I see from that I can create a machine config for my local machine but then that's confusing in itself as I thought that's what the 'Development' config was for. It mentions adding code to
Program.cs
to register the machine config but no mention of adding anything intoproperties/launchSettings.json
, which I thought was how the publish profile knew which config to use?I've never touched launch settings myself tbh, I normally just rely on appsettings.json for my live site and appsettings.develoment locally, I just like the idea of using the machine name method as it is then pretty obvious which is getting used.
So you have two database connection settings — one in appsettings.json and another in appsettings.development.json? And it just defaults such that the dev one is used locally but when it's deployed the publish task discards that and uses appsettings.json? So effectively you haven't taken any steps to create a production/release variation, you've just stuck with appsettings.json and appsettings.development.json and it 'just works'?
That would work for me — I don't have any desire to make things any more complicated, but would like to not have to manually switch connection strings every time I deploy. Am I understanding the above correctly? Thanks - appreciate the clarification.
Yes correct, I just don't push the appsettings.development to the server
is working on a reply...