Set-AzureServiceDiagnosticsExtension:无法绑定参数 'StorageContext'

Set-AzureServiceDiagnosticsExtension : Cannot bind parameter 'StorageContext'

我在 运行 这个脚本

时遇到以下错误
$storage_name = "<storage name>"
$key = "<key>"
$config_path="C:\diagnostics.wadcfgx"
$service_name="<service name>"
$storageContext = (New-AzureStorageContext -StorageAccountName $storage_name -StorageAccountKey $key)
Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $config_path -ServiceName $service_name -Slot Staging -Role WorkerRole1 

后面出现错误:

Set-AzureServiceDiagnosticsExtension : Cannot bind parameter 'StorageContext'. Cannot convert the "Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext" value of type
"Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext" to type "Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext".

我删除了变量 $storageContext 并将存储帐户名称和密钥值直接传递到如下命令中。

Set-AzureServiceDiagnosticsExtension -ServiceName $cloudService_name -Role $cloudWorkerRole_Name -StorageAccountName $wr_storageaccount_name -StorageAccountKey $wr_storageaccount_key -DiagnosticsConfigurationPath $local_configuration_path  -Slot Production

它worked.Thanks