Azure PowerShell-对象引用未设置为对象的实例 [英] Azure PowerShell - Object reference not set to an instance of an object

查看:60
本文介绍了Azure PowerShell-对象引用未设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写PowerShell脚本以使用Azure PowerShell自动执行EventHub创建.我正在此处并已安装Azure PowerShell模块(v 1.0.3).

I'm trying to write a PowerShell script to automate EventHub creation using Azure PowerShell. I am following the documentation outlined here and have installed the Azure PowerShell module (v 1.0.3).

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

I have added the Microsoft ServiceBus library (v3.0) using the following

$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 命令,例如

But as soon as I try and use the Get-AzureSBNamespace command, e.g.

$CurrentNamespace = Get-AzureSBNamespace -Name $Namespace

我收到以下错误

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

New-AzureSBNamespace 也是一样.我还尝试过使用 Login-AzureRmAccount 在同一会话中登录Azure,但是却获得了相同的对象null引用异常.

the same is true of New-AzureSBNamespace. I have also tried logging into Azure within the same session using Login-AzureRmAccount, but get the same object null reference exception.

这是一个错误,还是我缺少文档中未概述的内容?

Is this a bug, or am i missing something not outlined in the documentation?

推荐答案

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

This is because it uses the Service Management API and not the Resource Manager API. For me I ran:

Add-AzureAccount

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

And then Get-AzureSBNamespace and other SB cmdlets started working just fine.

这篇关于Azure PowerShell-对象引用未设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆