您好我正在尝试启用Web角色的诊断程序但是在运行脚本时我得到了以下错误 https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics
$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
Set-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:(:) [Set-AzureServiceDiagnosticsExtension],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand
答案 0 :(得分:3)
这似乎是一个已知问题,所有此类参数都应更改为公共接口类型IStorageContext
,以便它们独立于存储帐户版本。
作为一种变通方法,我们可以使用Set-AzureServiceDiagnosticsExtension
和-StorageAccountName
来使用-StorageAccountKey
cmdlet,如下所示:
Set-AzureServiceDiagnosticsExtension -StorageAccountName $storage_name -StorageAccountKey $key
我们也可以使用这个脚本来获取上下文:
$StorageAccount= Get-AzureStorageAccount -Name "YouStorageAccount"
$context= $StorageAccount.Context
此处类似案例,请参阅it。