We are having difficulty reading configuration section of our Azure App Service from the code. We have a specific need to read a flag from App Service's own configuration section. I have added the new property in Azure Portal to the App Service's Configuration section. I am following https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal
and
To read the variables as environment variables but with no luck.
I also want to mention that we are trying to read the configuration variables from our .NET Core 3.1 application and I have implemented the following three different ways to read the variable with all being unsuccessful:
var authType = configuration["AUTHTYPE"];
var authType2 = configuration.GetValue("AUTHTYPE");
var authType3 = Environment.GetEnvironmentVariable("AUTHTYPE");
AUTHTYPE is the name of the configuration in the local configuration section of the app service. I have tried reading this configuration as "AUTHTYPE", "AS.NETCORE_AUTHTYPE" and "APPSETTING_AUTHTYPE" and all have failed to retrieve the value.
Please help us on how to access these variables as this problem is currently blocking us. Please also let me know if you need more information or details. Thank you,
Murat
To get the rid of the issue,Please make sure that below workaround you have setup in Azure portal.
Navigate to Azure Portal > Configuration > New Application setting and add AS.NETCORE_ENVIRONMENT
And make sure that in your application should have appsettings.json
file
For complete setup please refer the below links:
MICROSOFT DOCUMENTATION:- Environment variables and app settings in Azure App Service.
SO THREAD: How and where to define environment variables. & read environment variable from azure app service configuration from REACT app as suggested by @ Jason Pan
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.