I am trying to access the SQL connection string within .net core api project. My controller is using the following code to get it but the value of szDSN remains null.
string szDSN = Environment.GetEnvironmentVariable("DSNSQLConnectionString");
and I add it in my appsettings.json like this
"Values": {
"DSNSQLConnectionString": "Data Source=(local);Initial Catalog=local;User Id=abc; Password=123"
},
I used the same way of getting my SQL connection in .net core project of type functions and it worked fine.. But for some reason its not pulling the value from appsettting.json in API type of project. What am I doing incorrectly?
I am going to need to add many more configuration variables in this project which I will need in the controllers, not sure why Environment.GetEnvironmentVariable is not grabbing variable values from appsettings.json