Azure CloudStorageAccount.SetConfigurationSettingPublisher() invalid after upgrading to 2.0

1.8k Views Asked by At

Hi I am struggling to understand/find a solution to this problem. I have removed the reference to StorageClient 1.7 and the project now uses Storage (2.0). I have a web role like this:

 public override bool OnStart()
    {
        CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>     
configSetter(
           RoleEnvironment.GetConfigurationSettingValue(configName)));

The method SetConfigurationSettingPublisher() does not exist.

Whats does this method do, and how do I replace it? I have seen things like below but don't understand what's happening. What is the _cloudStorageAccount variable and where is it used? What the point of assigning it to this variable? Would storageSettingName be "DataConnectionString" from Service config? Do I need this at all or can it be omitted?

  • var setting = CloudConfigurationManager.GetSetting(storageSettingName);
  • _cloudStorageAccount = CloudStorageAccount.Parse(setting);
1

There are 1 best solutions below

0
kwill On

The MSDN documentation for CloudStorageAccount.Parse shows how to use it:

CloudStorageAccount storageAccount = 
CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageAccountConnectionString"]);

The StorageAccountConnectionString would be a setting in your csdef/cscfg which would look something like:

<Setting name="StorageAccountConnectionString"
         value="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=+Ngl4GVRy01UUy5uL4cFqoufI/79xWqBAHkNmYODycfY8QW5dZXzqg58AZl1XxJWvGgEUdW/smr1DvfwuyC1jw==" 
         />