【问题标题】:Azure PowerShell - Object reference not set to an instance of an objectAzure PowerShell - 对象引用未设置为对象的实例
【发布时间】:2016-01-24 19:43:57
【问题描述】:

我正在尝试编写一个 PowerShell 脚本来使用 Azure PowerShell 自动创建 EventHub。我正在关注here 概述的文档,并已安装 Azure PowerShell 模块 (v 1.0.3)。

我使用以下代码添加了 Microsoft ServiceBus 库 (v3.0)

$scriptPath = Split-Path -parent $PSCommandPath
$dllPath = "$scriptPath\..\..\packages\WindowsAzure.ServiceBus.3.1.2\lib\net45-full\Microsoft.ServiceBus.dll"
Add-Type -Path $dllPath

但是一旦我尝试使用Get-AzureSBNamespace 命令,例如

$CurrentNamespace = Get-AzureSBNamespace -Name $Namespace

我收到以下错误

Get-AzureSBNamespace : Object reference not set to an instance of an object.

New-AzureSBNamespace 也是如此。我还尝试使用Login-AzureRmAccount 在同一会话中登录 Azure,但得到相同的对象空引用异常。

这是一个错误,还是我遗漏了文档中未列出的内容?

【问题讨论】:

  • 我想跳过其他一些安全漏洞吗?例如SSL证书等

标签: powershell azure servicebus


【解决方案1】:

这是因为它使用服务管理 API 而不是资源管理器 API。对我来说,我跑了:

Add-AzureAccount

然后 Get-AzureSBNamespace 和其他 SB cmdlet 开始正常工作。

【讨论】:

    【解决方案2】:

    如果你可以使用 PS 5.0 试试这个:msdn

    【讨论】:

    • Thnx,但仍然没有喜悦。遵循您提供的链接中描述的所有步骤,但在尝试 cmdlet Get-AzureRmSubscriptions 时,我收到错误 The term 'Get-AzureRmSubscriptions' is not recognized as the name of a cmdlet。没有发现这些 cmdlet 很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 2020-07-13
    相关资源
    最近更新 更多