Reputation: 5546
before migrating to 2.0, the code below worked (type CloudStorageAccount was in namespace StorageClient):
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
, bit this type does not have the method CreateRoleInstanceDiagnosticManager
So how can I get the instance returned by CreateRoleInstanceDiagnosticManager previously, as I use it for my Performance Counters and Logs
Upvotes: 4
Views: 9383
Reputation: 3800
It certainly looks like there was a change at 2.0 and doesn't act like an extension method any more - which means you may not need the CloudStorageAccount you have at the top I just ran into this myself.
Try this:
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(
RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
var roleInstanceDiagnosticManager = CloudAccountDiagnosticMonitorExtensions.CreateRoleInstanceDiagnosticManager(
RoleEnvironment.GetConfigurationSettingValue(wadConnectionString),
RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
Upvotes: 5
Reputation: 9516
It does not work, as CreateRoleInstanceDiagnosticManager extension references an old CloudStorageAccount. The 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 reference an old Microsoft.WindowsAzure.StorageClient, as AzureDiagnostics references that assembly.
Upvotes: 0
Reputation: 20571
What you do is first include the following name space:
using Microsoft.WindowsAzure.Diagnostics.Management;
Then use the code below:
CloudStorageAccount cloudStorageAccount =
cloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue
(wadConnectionString));
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
cloudStorageAccount.CreateRoleInstanceDiagnosticManager
(RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name,
RoleEnvironment.CurrentRoleInstance.Id);
I just tested above code with SDK 1.8 & Storage Client 2.0.
Upvotes: 0