Jacek
Jacek

Reputation: 12053

ConfigurationManager on Azure environment

I use this below code to read configuration. This code is used in global.asax Application_Start method.

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

It works great in my local configuration (appSetting.config), but when I push my code to Azure. It not works.

Entry ShowAllMethodsInSwaggerDocs is visible in Azure panel with proper value (I add node in *.csdef and *.cscfg), but this value is not used. Why? Maybe should I use other class than ConfigurationManager?

Upvotes: 1

Views: 2737

Answers (1)

Rob
Rob

Reputation: 27367

You need to use the nuget package Microsoft Azure Configuration Manager to pick up the configuration settings both in the portal, and in your web.config.

Upvotes: 2

Related Questions