嗨,我正在尝试启用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 Scripts \ Enable Web Role Diagnostics.ps1:6 char:54 ... reServiceDiagnosticsExtension -StorageContext $ storageContext -Diagno ... ~~~~~~~~~~~~~~~ CategoryInfo:InvalidArgument:(:) [Set-AzureServiceDiagnosticsExtension],ParameterBindingException FullyQualifiedErrorId:CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand
1 回答
这似乎是一个已知问题,所有这些参数都应该更改为公共接口类型
IStorageContext
,以便它们独立于存储帐户版本 .作为解决方法,我们可以使用
-StorageAccountName
和-StorageAccountKey
来使用Set-AzureServiceDiagnosticsExtension
cmdlet,如下所示:我们也可以使用这个脚本来获取上下文:
这里有类似的情况,请参考it .