【问题标题】:Not able to enable Diagnostics for web role using powershell无法使用 powershell 为 Web 角色启用诊断
【发布时间】:2017-10-06 13:55:45
【问题描述】:

您好,我正在尝试启用 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:无法绑定参数 '存储上下文'。无法转换 “Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”的值 键入“Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext”到 类型 “Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext”。 在 E:\TK_Backup\Drive\PowerShell 脚本\启用 Web 角色 诊断.ps1:6 字符:54 + ... reServiceDiagnosticsExtension -StorageContext $storageContext -Diagno ... +~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-AzureServiceDiagnosticsExtension], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsExtensionCommand

【问题讨论】:

    标签: powershell azure-web-roles azure-powershell


    【解决方案1】:

    这似乎是一个已知问题,所有此类参数都应该已更改为通用接口类型IStorageContext,以便它们独立于存储帐户版本。

    作为一种解决方法,我们可以通过使用-StorageAccountName-StorageAccountKey 来使用Set-AzureServiceDiagnosticsExtension cmdlet,如下所示:

    Set-AzureServiceDiagnosticsExtension -StorageAccountName $storage_name -StorageAccountKey $key
    

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

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

    这里有类似情况,请参考it

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-23
      • 1970-01-01
      • 2018-02-10
      • 2021-08-21
      • 2023-03-23
      • 1970-01-01
      • 2022-07-24
      相关资源
      最近更新 更多