CloudStorageAccount

before porting to 2.0, the following code (CloudStorageAccount type was in the StorageClient namespace):

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue(wadConnectionString)); var roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager( RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id); 

StorageClient was removed in 2.0, so now I have to use

 Microsoft.WindowsAzure.Storage.CloudStorageAccount 

a bit of this type does not have a CreateRoleInstanceDiagnosticManager method

So how can I get the instance returned by CreateRoleInstanceDiagnosticManager earlier as I use it for my performance counters and logs

+4
source share
3 answers

Of course, it seems that the change in 2.0 has occurred and no longer acts as an extension method - this means that you may not need the CloudStorageAccount, which you have at the top, which I just came across this myself.

Try the following:

 CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse( RoleEnvironment.GetConfigurationSettingValue(wadConnectionString)); var roleInstanceDiagnosticManager = CloudAccountDiagnosticMonitorExtensions.CreateRoleInstanceDiagnosticManager( RoleEnvironment.GetConfigurationSettingValue(wadConnectionString), RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id); 
+5
source

First of all, you include the following namespace:

 using Microsoft.WindowsAzure.Diagnostics.Management; 

Then use the following code:

  CloudStorageAccount cloudStorageAccount = cloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue (wadConnectionString)); RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager (RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id); 

I just tested the above code with SDK 1.8 and Storage Client 2.0.

0
source

This does not work because the CreateRoleInstanceDiagnosticManager extension references the old CloudStorageAccount. A workaround would be to use DeploymentDiagnosticManager

 var storageConnectionString = RoleEnvironment.GetConfigurationSettingValue( "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"); var deploymentDiagnosticManager = new DeploymentDiagnosticManager( storageConnectionString, RoleEnvironment.DeploymentId); return deploymentDiagnosticManager.GetRoleInstanceDiagnosticManager( RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);` 

In addition to Microsoft.WindowsAzure.Storage, you need to refer to the old Microsoft.WindowsAzure.StorageClient file, since AzureDiagnostics refers to this assembly.

0
source

All Articles