If you are currently migrating your application to Azure environment using WebRole, you might need to move your appsettings in Web configuration (web.config) to Azure Service configuration (.cscfg file). By using this approach, you may change your configurations directly from Azure Portal.
So, here are the steps:
- Add settings from WebRole properties based on your appsettings section in your webconfig
- Change your code from ConfigurationManager.AppSettings[“configs”]; to CloudConfigurationManager.GetSetting(“configs”);
And we’re done… and here are the rules of thumb:
- If the application runs on Azure environment (Local Simulator and Cloud), it will look for the settings in .cscfg file first, if the setting couldn’t be found in .cscfg file, it will search in web.config, and if web.config doesn’t contain the desired setting, it will return null.
- If the application runs on Local environment, it will look for the settings in web.config only, if the settings couldn’t be found, it will return null.