cloudStorageAccount

Rya*_*yan 4 c# azure azure-storage

在迁移到2.0之前,下面的代码工作(类型CloudStorageAccount在名称空间StorageClient中):

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(
    RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));


var roleInstanceDiagnosticManager = cloudStorageAccount.CreateRoleInstanceDiagnosticManager(
    RoleEnvironment.DeploymentId,
    RoleEnvironment.CurrentRoleInstance.Role.Name,
    RoleEnvironment.CurrentRoleInstance.Id);
Run Code Online (Sandbox Code Playgroud)

StorageClient已在2.0中删除,所以现在我必须使用

Microsoft.WindowsAzure.Storage.CloudStorageAccount
Run Code Online (Sandbox Code Playgroud)

,bit这种类型没有CreateRoleInstanceDiagnosticManager方法

那么我如何才能获得CreateRoleInstanceDiagnosticManager先前返回的实例,因为我将它用于我的性能计数器和日志

Jas*_*ley 5

它看起来确实在2.0处有变化并且不再像扩展方法那样 - 这意味着您可能不需要您在顶部拥有的CloudStorageAccount我自己也遇到过这种情况.

试试这个:

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(
                       RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));

var roleInstanceDiagnosticManager = CloudAccountDiagnosticMonitorExtensions.CreateRoleInstanceDiagnosticManager(
            RoleEnvironment.GetConfigurationSettingValue(wadConnectionString),
            RoleEnvironment.DeploymentId,
            RoleEnvironment.CurrentRoleInstance.Role.Name,
            RoleEnvironment.CurrentRoleInstance.Id);
Run Code Online (Sandbox Code Playgroud)