Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to create a new web app service in Azure from powershell, but running into the following error:

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 
like image 501
Stuart.Sklinar Avatar asked Jan 17 '17 09:01

Stuart.Sklinar


1 Answers

Get-AzureSubscription and Select-AzureSubscription are ASM cmdlets. I notice that you want to create a ARM webapp. If you have multiple ARM subscriptions, using Select-AzureSubscription you could not change the default subscription. The cmdlet only change classic subscriptions.

You need use ARM cmdlets.

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

like image 64
Shui shengbao Avatar answered Oct 25 '22 04:10

Shui shengbao