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


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];


Comments (3)

  1. Alexandre Brisebois says:

    This seems to have been removed from the latest SDK (october 2012)

  2. Cesar says:

    Windows Azure is a 'PaaS Cloud', so you need to specify 'Cloud Configuration' (like Web-Role numbers, VM size, etc.) in any higher level place that the internal web.config.

    I recommend to explore Windows Azure architecture and possibilities before making tha kind of statement.

  3. MichaelD! says:

    Wow… yet another configuration file to concern ourselves with. 😐 Unbelievable.

Skip to main content