How to solve “SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used” After Moving to Windows Azure SDK 1.3

Cesar De la Torre


A quick reminder:

After Windows Azure SDK 1.3, we now use full IIS instead HWC (Hosted Web Core). Using IIS we can have several WebSites per WebRole, so now the internal architecture and processes are different, this is why we have to change the we we use the API regarding Windows Azure configuration settings.

Basically, in case you’re using ASP.NET, we need to add the following code to our Global.asax

Global.asax in ASP.NET

        protected void Application_Start()
            //(CDLTLL) Configuration for Windows Azure settings
                (configName, configSettingPublisher) =>
                    var connectionString =

Here is an interesting post regarding how to solve this issue, for detailed information:

Then, if you want to get a connection string (like ADO.NET or EF connString) from WA-Conf-Settings or from a regular Web.config, depending on what environment you are running your app, you can check if you are running on Windows Azure using ‘RoleEnvironment.IsAvailable’, so doing the following can be very useful:

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
    string connectionString;

    if (RoleEnvironment.IsAvailable)
        connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);
        connectionString = ConfigurationManager.AppSettings[configName];



Discussion is closed.

Feedback usabilla icon