0

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

https://learn.microsoft.com/en-us/azure/app-service/configure-language-dotnetcore?pivots=platform-windows#access-environment-variables

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", "ASPNETCORE_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

1 Answers1

0

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 ASPNETCORE_ENVIRONMENT

enter image description here

And make sure that in your application should have appsettings.json file

enter image description here

For complete setup please refer the below links:

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15