簡體   English   中英

Azure PowerShell-對象引用未設置為對象的實例

[英]Azure PowerShell - Object reference not set to an instance of an object

我正在嘗試編寫PowerShell腳本以使用Azure PowerShell自動執行EventHub創建。 我正在遵循此處概述的文檔並已安裝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在同一會話中Login-AzureRmAccount ,但是得到相同的對象null引用異常。

這是一個錯誤,還是我缺少文檔中未概述的內容?

這是因為它使用服務管理API,而不使用資源管理器API。 對我來說,我跑了:

Add-AzureAccount

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

如果可以使用PS 5.0,請嘗試以下操作: msdn

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM