‘CloudStorageAccount’ does not exist in the namespace ‘Microsoft.WindowsAzure’

In case this helps someone, I upgraded my Azure Storage assemblies and found a breaking change to the Azure storage classes. The error manifests itself as:

The type or namespace name ‘CloudStorageAccount’ does not exist in the namespace ‘Microsoft.WindowsAzure’ (are you missing an assembly reference?)

And most likely stems from code similar to the following:

Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher( ( configName, configSetter ) =>
            {
                configSetter( Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue( configName ) );
            } );

It was simple enough to fix:

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                // Provide the configSetter with the initial value
                configSetter(ConfigurationManager.AppSettings[configName]);
 
            });

When the storage account is created, you need to identify the settings name that the connection string is defined in:

var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

To be complete, the following illustrates how the web.config or app.config could be defined:

<appSettings>
    <add key="DataConnectionString" value="UseDevelopmentStorage=true" />
</appSettings>
This entry was posted in Azure, AzureStorage, C# and tagged , . Bookmark the permalink.

One Response to ‘CloudStorageAccount’ does not exist in the namespace ‘Microsoft.WindowsAzure’

  1. smart lipo says:

    Your method of describing all in this post is genuinely pleasant, all can effortlessly understand it, Thanks a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>