Have you spent your hours getting rid of below exception ?


I spent. So in this blog post, I am trying to save your time.

Very first let us understand why this error occurs?

Azure application runs in Full IIS model from SDK 1.3 onwards.

In simple English we can say that from SDK 1.3 onwards WebRole.cs and Web Application codes run in different application domain. So if we write or we do have code for Set Configuration setting in WebRole.cs then we are going to get above exception.

How to solve?

1. Make sure you have Diagnostic connection string in settings of Web Role.


2. See if in your Web Role project Global.asax file exist. If it does not exist then right click on the Web Role project and add one.

3. Open Global.asax.cs file and in Application_Strat() add the below code


Bottom line is to get rid of below exception, you need to copy below code in Application_Strat() .

Code to copy

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSettingPublisher) =>
var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);

I hope this post may have saved your some time.


4 thoughts on “Windows Azure for Developers Task 12: SetConfigurationSettingPublisher needs to be called before FromConfiguration Setting can be used error

  1. You don’t need to bother with SetConfigurationSettingPublisher() if you use the following instead:

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(“DataConnectionString”));

  2. Hi Neil ,

    Thanks for sharing. I just tried your solution and it is working fine.

    Thanks again for sharing.

    var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(“DataConnectionString”));

    I will make one more blog post on the same such that community would get benifited

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s