Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Schwartz 5 posts 75 karma points
    1 week ago
    Michael Schwartz
    0

    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 :)

  • Corné Hoskam 74 posts 577 karma points MVP c-trib
    1 week ago
    Corné Hoskam
    1

    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é

  • Michael Schwartz 5 posts 75 karma points
    1 week ago
    Michael Schwartz
    0

    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

  • Huw Reddick 1031 posts 3490 karma points c-trib
    1 week ago
    Huw Reddick
    0

    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.

  • Michael Schwartz 5 posts 75 karma points
    1 week ago
    Michael Schwartz
    0

    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.

  • Huw Reddick 1031 posts 3490 karma points c-trib
    1 week ago
    Huw Reddick
    0

    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

  • Michael Schwartz 5 posts 75 karma points
    1 week ago
    Michael Schwartz
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft