简体   繁体   中英

Reading Configuration Section of an App Service

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-do.netcore?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", "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:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM