New-AzureRmResourceGroup:'this.Client.SubscriptionId'不能为null

Stu*_*nar 2 powershell azure alm azure-web-sites azure-powershell

我正在尝试从powershell在Azure中创建一个新的Web应用程序服务,但遇到以下错误:

New-AzureRmResourceGroup : 'this.Client.SubscriptionId' cannot be null.

$webAppName = "powershelldemowebapp"
$ResourceGroupName = "PowerShellResourceGroup"          
$Location = "East Asia"

Login-AzureRmAccount -ServicePrincipal -Tenant 000000-0000-0000-0000-00000 -Credential $psCred
Get-AzureSubscription
Select-AzureSubscription  -SubscriptionId 00000-0000-0000-000-0000
New-AzureRmWebApp -Name $webAppName  -ResourceGroupName $ResourceGroupName  -Location $Location 
Run Code Online (Sandbox Code Playgroud)

Shu*_*bao 9

Get-AzureSubscription并且Select-AzureSubscription是ASM cmdlet.我注意到你想创建一个ARM webapp.如果您有多个ARM订阅,则使用Select-AzureSubscription您无法更改默认订阅.cmdlet仅更改经典订阅.

您需要使用ARM cmdlet.

Get-AzureRmSubscription Select-AzureRmSubscription -SubscriptionId 00000-0000-0000-000-0000