I have an Azure App service and I have deployed my react js app.
In my local development environment, I have my appsettings.Development.json
with the following setting:
"ConnectionStrings": {
"setting": "<connectionstring_details>",
},
This setting needs to be set in my Azure app.
I have gone to the app under Environment variables --> ConnectionStrings and added a setting called "setting" and added the connectionstring_details
value, but it did not work.
If I allow it to get the value from the appsettings.json
file, not appsettings.Development.json
because it is a release mode it works fine.
The way I retrieve the value in code is as follows:
public HomeController(IConfiguration configuration)
{
MyValue = configuration.GetConnectionString("setting");
}
How can I set this value?
Do I need to just set it in the environment variables and not the connection strings ?
I have an Azure App service and I have deployed my react js app.
In my local development environment, I have my appsettings.Development.json
with the following setting:
"ConnectionStrings": {
"setting": "<connectionstring_details>",
},
This setting needs to be set in my Azure app.
I have gone to the app under Environment variables --> ConnectionStrings and added a setting called "setting" and added the connectionstring_details
value, but it did not work.
If I allow it to get the value from the appsettings.json
file, not appsettings.Development.json
because it is a release mode it works fine.
The way I retrieve the value in code is as follows:
public HomeController(IConfiguration configuration)
{
MyValue = configuration.GetConnectionString("setting");
}
How can I set this value?
Do I need to just set it in the environment variables and not the connection strings ?
Share Improve this question edited Mar 6 at 6:14 Sirra Sneha 1,3482 gold badges3 silver badges10 bronze badges asked Mar 6 at 2:26 ClarisaClarisa 14 bronze badges 1 |1 Answer
Reset to default 0Actually, if you set the connections string inside the environment variable's connection string tab as below, you could directly get the connection string by using the configuration.GetConnectionString("setting")
My codes:
public HomeController(IConfiguration configuration)
{
Myvalue = configuration.GetConnectionString("setting") != null ? configuration.GetConnectionString("setting"): "test";
}
Result:
ConnectionStrings_setting
instead of using the Connection Strings section. – Sirra Sneha Commented Mar 6 at 6:39