Wednesday, March 9, 2011

Azure "SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used"

When you get the following exception: 

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

A work around is to retrieve you connection string using CloudStorageAccount's Parse() method instead of the FromConfigurationSetting() method.  For example, replace:

        private static CloudStorageAccount storageAccount =
        CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

with:

        private static CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
            RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));

4 comments: