代码之家  ›  专栏  ›  技术社区  ›  Jacek

Azure环境上的ConfigurationManager

  •  1
  • Jacek  · 技术社区  · 10 年前

    我使用下面的代码来读取配置。此代码用于全局。asax Application_Start方法。

            var showAllMethodSetting = ConfigurationManager.AppSettings["ShowAllMethodsInSwaggerDocs"];
            bool showAllMethods;
            if (!bool.TryParse(showAllMethodSetting, out showAllMethods) || !showAllMethods)
            {
                ... code ...
            }
    

    它在我的本地配置(appSetting.config)中运行良好,但当我将代码推送到Azure时。它不起作用。

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

    1 回复  |  直到 9 年前
        1
  •  2
  •   Rob    10 年前

    你需要使用nuget包 Microsoft Azure Configuration Manager 在门户和web.config中获取配置设置。

    推荐文章