My Umbraco works with MS-SQL that rotates the password every month.
Because of the rotation, the password that I have in my appsettings in no more relent. To fix this, I need to stop the server, edit the appsettings with the new password and then start again the server.
I would like to know if there is a way to change the connection string that Umbraco uses on runtime (umbracoDbDSN)). Then when the rotation occurs I can programmably replace with the new password.
Perhaps storing the connectionstring in an environment variable would be an option for you, instead of storing it in the appsettings? That way you can change the variable without having to edit the appsettings file constantly.
This method will however still require you to still restart your application after changing, as it doesn't automatically reload after you've changed it (As far as I am aware!).
Our architecture is that the windows server and the DB are do not know about one to another only through middleware. We do not have AD so we can not use this method.
I assume the the best option will come on the C# dotnet level.
Changing connectionstring on runtime
Hey,
My Umbraco works with MS-SQL that rotates the password every month. Because of the rotation, the password that I have in my appsettings in no more relent. To fix this, I need to stop the server, edit the appsettings with the new password and then start again the server.
I would like to know if there is a way to change the connection string that Umbraco uses on runtime (umbracoDbDSN)). Then when the rotation occurs I can programmably replace with the new password.
Thanks in advance :)
Hi Michael,
Perhaps storing the connectionstring in an environment variable would be an option for you, instead of storing it in the appsettings? That way you can change the variable without having to edit the appsettings file constantly.
This method will however still require you to still restart your application after changing, as it doesn't automatically reload after you've changed it (As far as I am aware!).
Kind regards, Corné
Thank you for your replay.
However, I seek a solution that will not need to restart the application.
Putting the password in appsettings and or environment variable will still need to restart the application.
Is there a way to restart the service only in the program.cs in case of a failure?
Regards, Michael
If you use the built in windows APP POOL\appname user and a trusted connection you would not need to rotate your appsettings config every month.
Our architecture is that the windows server and the DB are do not know about one to another only through middleware. We do not have AD so we can not use this method.
I assume the the best option will come on the C# dotnet level.
I know this is possible in standard .net core but no idea if it is possible in Umbraco
https://medium.com/@niteshsinghal85/handling-database-password-change-at-runtime-with-entity-framework-in-asp-net-core-9caa81827cef
I tried this method but unfortunately this solution is invalid to Umbraco...
I hope there will be a way to change on runtime in the future.
Hi Michael,
Did you find any solution for this?
is working on a reply...