C# Azure环境上的ConfigurationManager

C# Azure环境上的ConfigurationManager,c#,.net,azure,asp.net-web-api,configuration,C#,.net,Azure,Asp.net Web Api,Configuration,我使用下面的代码来读取配置。此代码用于global.asax应用程序的启动方法 var showAllMethodSetting = ConfigurationManager.AppSettings["ShowAllMethodsInSwaggerDocs"]; bool showAllMethods; if (!bool.TryParse(showAllMethodSetting, out showAllMethods) || !showAllM

我使用下面的代码来读取配置。此代码用于global.asax应用程序的启动方法

        var showAllMethodSetting = ConfigurationManager.AppSettings["ShowAllMethodsInSwaggerDocs"];
        bool showAllMethods;
        if (!bool.TryParse(showAllMethodSetting, out showAllMethods) || !showAllMethods)
        {
            ... code ...
        }
它在我的本地配置(appSetting.config)中非常有效,但是当我将代码推送到Azure时。它不起作用


条目ShowAllMethodsInSwiggerDocs在Azure面板中以适当的值可见(我在*.csdef和*.cscfg中添加了节点),但未使用此值。为什么?也许我应该使用ConfigurationManager以外的其他类?

您需要使用nuget软件包来获取门户中的配置设置,在您的Web.CONFIG.

中,在应用程序部署之后添加了门户设置,使用相同的名称是应用程序设置和门户设置吗?您可能需要考虑一个抽象的库——“Jacek Yep,它绝对应该!”它本质上是一个从azure配置读取的包,然后返回到通常的
*.config
文件