In Azure function v1, am trying to read the connection string present in local.settings.json using GetEnvironmentVariable static method
Here is my local.settings.json file
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
},
"ConnectionStrings": {
"OnPremisesConnection": "Server=test;Initial Catalog=testdb;Integrated Security=SSPI;"
}
}
using the following code am reading the connection string
string variableName = "OnPremisesConnection";
var res = Environment.GetEnvironmentVariable($"ConnectionStrings:{variableName}")
but am getting NULL as result. What am I missing here ?
ConfigurationManager.ConnectionStrings[variableName]option? I'm not sure if Environment variables should/will work locally.v1, am advised to useGetEnvironmentVariablefor better support in futureGetEnvironmentVariablecan't get ConnectStrings as they are not imported into environment, only Values are available. I will update my answer in your last question.