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); configSettingPublisher(connectionString); } );
I hope this post may have saved your some time.
Leave a Reply