2017-10-06 92 views
1

你好我试图使Web角色的诊断,从而使Web角色诊断,但是当运行脚本,我得到了以下错误 https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics无法使用PowerShell

$storage_name = "testdeploy" 
$key = "keyvalue" 
$config_path="E:\Tempvs\AzureCloudService3\AzureCloudService3\bin\Release\app.publish\Extensions\PaaSDiagnostics.MvcWebRole1.PubConfig.xml" 
$service_name="testmyjsdiag" 
$storageContext = New-AzureStorageContext -StorageAccountName $storage_name -StorageAccountKey $key 
Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $config_path -ServiceName $service_name -Slot Production -Role MvcWebRole1 

集-AzureServiceDiagnosticsExtension:不能绑定参数 'StorageContext'。不能 型“Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”的 “Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”值转换为 型 “Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext”。 在E:\ TK_Backup \ Drive \ PowerShell脚本\启用Web角色 Diagnostics.ps1:6 char:54 + ... reServiceDiagnosticsExtension -StorageContext $ storageContext -Diagno ... + ~~~~~~~~~ ~~~~~~ + CategoryInfo:InvalidArgument:(:) [设置AzureServiceDiagnosticsExtension],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand

回答

3

这似乎是一个已知的问题,所有这些参数应该已经更改为通用接口类型IStorageContext,以便它们独立于sto愤怒账户版本。

作为一种变通方法,我们可以使用Set-AzureServiceDiagnosticsExtension cmdlet的使用-StorageAccountName-StorageAccountKey,像这样:

Set-AzureServiceDiagnosticsExtension -StorageAccountName $storage_name -StorageAccountKey $key 

此外,我们可以使用这个脚本来获取上下文:

$StorageAccount= Get-AzureStorageAccount -Name "YouStorageAccount" 
$context= $StorageAccount.Context 

这里一类似的情况请参考it