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 6 posts 76 karma points
    Jan 17, 2023 @ 13:14
    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 80 posts 587 karma points MVP 2x c-trib
    Jan 17, 2023 @ 13:31
    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 6 posts 76 karma points
    Jan 17, 2023 @ 14:16
    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 1727 posts 6066 karma points MVP c-trib
    Jan 17, 2023 @ 14:23
    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 6 posts 76 karma points
    Jan 17, 2023 @ 18:45
    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 1727 posts 6066 karma points MVP c-trib
    Jan 18, 2023 @ 09:00
    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 6 posts 76 karma points
    Jan 19, 2023 @ 08:49
    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.

  • Nijaz Hameed 30 posts 164 karma points
    5 days ago
    Nijaz Hameed
    0

    Hi Michael,

    Did you find any solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft