One code, two apps, different connection strings. How to managed that problem on core 2 [Music no 6]

I want to host two applications on one Linux server. One app for dev, another app for users. The problem which I have is that I try managed with sensitive data like connection string. Both databases (for dev and prod) are available on the Internet. Ideally, I want to write an app on the Windows, then push changes to GitHub, next go to console in Linux, get latest changes and build the app with proper commend either as the prod or as the dev build.

I don’t want to hardcode sensitive values in code or put them to a json file because by mistake I could commit that to GitHub. In that case, I decided to use SecretManager Tool in core 2. How is it work is nicely explained: and

My secret.json looks like that:

So with one code, I want to be able to choose which connection string I want to use without changing environment variables on Linux. In that case, I decided to run the app with some commands. The idea comes from

To select proper connection string I use that code:

And it’s work!



Other links:

Powered by: Wordpress