New-AzureRmResourceGroup: ‘this.Client.SubscriptionId’ cannot be null

In this azure tutorial, we will discuss how to fix the error, New-AzureRmResourceGroup: ‘this.Client.SubscriptionId’ cannot be null.

New-AzureRmResourceGroup: ‘this.Client.SubscriptionId’ cannot be null

The above error came while trying to execute the below cmdlet to create the Azure web app using PowerShell ISE in Azure.

Login-AzureRmAccount
#Specify the Web app Name and Region
$mywebapp = "MyNewWebApp468"  
$myloc = "Central US"  
$myAppPlan = "MyWebApps"
New-AzureRmResourceGroup -Name mynewupdtrsggroup -Location $myloc
New-AzureRmAppServicePlan -Name $myAppPlan -Location $myloc -ResourceGroupName newresgroup -Tier Free
New-AzureRmWebApp -Name $mywebapp -Location $myloc -AppServicePlan $myAppPlan -ResourceGroupName newresgroup 
New-AzureRmResourceGroup  'this.Client.SubscriptionId' cannot be null.

The complete error message is

New-AzureRmResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.
At line:9 char:1

  • New-AzureRmResourceGroup -Name mynewupdtrsggroup -Location $myloc
  • ~~~~~~~~~~~~~
    • CategoryInfo : CloseError: (:) [New-AzureRmResourceGroup], ValidationException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupCmdlet

New-AzureRmAppServicePlan : ‘this.Client.SubscriptionId’ cannot be null

I also got the error “New-AzureRmAppServicePlan: ‘this.Client.SubscriptionId’ cannot be null”. Which came while trying to execute the below cmdlet to create the Azure web app using PowerShell ISE in Azure.

Login-AzureRmAccount
#Specify the Web app Name and Region
$mywebapp = "MyNewWebApp468"  
$myloc = "Central US"  
$myAppPlan = "MyWebApps"
New-AzureRmResourceGroup -Name mynewupdtrsggroup -Location $myloc
New-AzureRmAppServicePlan -Name $myAppPlan -Location $myloc -ResourceGroupName newresgroup -Tier Free
New-AzureRmWebApp -Name $mywebapp -Location $myloc -AppServicePlan $myAppPlan -ResourceGroupName newresgroup 
New-AzureRmAppServicePlan  'this.Client.SubscriptionId' cannot be null

The complete error message is

New-AzureRmAppServicePlan : ‘this.Client.SubscriptionId’ cannot be null.
At line:7 char:1

  • New-AzureRmAppServicePlan -Name $myAppPlan -Location $myloc -Resource …
  • ~~~~~~~~~~~~~~~~~
    • CategoryInfo : CloseError: (:) [New-AzureRmAppServicePlan], ValidationException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans.NewAzureAppServicePlanCmdlet

New-AzureRmWebApp : ‘this.SubscriptionId’ cannot be null

I also got the error “New-AzureRmWebApp: ‘this.SubscriptionId’ cannot be null”. Which came while trying to execute the below cmdlet to create the Azure web app using PowerShell ISE in Azure.

Login-AzureRmAccount
#Specify the Web app Name and Region
$mywebapp = "MyNewWebApp468"  
$myloc = "Central US"  
$myAppPlan = "MyWebApps"
New-AzureRmResourceGroup -Name mynewupdtrsggroup -Location $myloc
New-AzureRmAppServicePlan -Name $myAppPlan -Location $myloc -ResourceGroupName newresgroup -Tier Free
New-AzureRmWebApp -Name $mywebapp -Location $myloc -AppServicePlan $myAppPlan -ResourceGroupName newresgroup 
New-AzureRmWebApp 'this.SubscriptionId' cannot be null

The complete error message is

New-AzureRmWebApp : ‘this.SubscriptionId’ cannot be null.
At line:8 char:1

  • New-AzureRmWebApp -Name $mywebapp -Location $myloc -AppServicePlan $m …
  • ~~~~~~~~~~~~~~~~~
    • CategoryInfo : CloseError: (:) [New-AzureRmWebApp], ValidationException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.NewAzureWebAppCmdlet

Solution[Solved]

To fix all the above three issues, we need to add the below cmdlets to the script

Get-AzureRmSubscription
Select-AzureRmSubscription  -SubscriptionId xxxx4300-yyyy-xx18-9c9c-feaa72a5cbd1

To get your subscriptionId, Login to the Azure portal and then search for the Subscription

How to get your subscriptionId in Azure portal

Now click on the search result Subscriptions, Use the below SubscriptionId. In case of multiple subscription choose the correct one.

How to get your subscriptionId in Azure portal

Now the complete script will be

Login-AzureRmAccount
Get-AzureRmSubscription
Select-AzureRmSubscription  -SubscriptionId xxxx4300-yyyy-xx18-9c9c-feaa72a5cbd1
#Specify the Web app Name and Region
$mywebapp = "MyNewWebApp468"  
$myloc = "Central US"  
$myAppPlan = "MyWebApps"
New-AzureRmResourceGroup -Name mynewupdtrsggroup -Location $myloc
New-AzureRmAppServicePlan -Name $myAppPlan -Location $myloc -ResourceGroupName newresgroup -Tier Free
New-AzureRmWebApp -Name $mywebapp -Location $myloc -AppServicePlan $myAppPlan -ResourceGroupName newresgroup 
New-AzureRmWebApp 'this.SubscriptionId' cannot be null how to fix

Note: Verify your subscription is ASM or ARM. Here in this case your Azure subscription should be ARM.

If you have only ASM subscription then you need to add the ARM subscription.

This will fix all these above three errors.

You may like following Azure tutorials:

In this Azure tutorial, we discussed how to fix the below three errors, 

  • New-AzureRmResourceGroup: ‘this.Client.SubscriptionId’ cannot be null
  • New-AzureRmAppServicePlan : ‘this.Client.SubscriptionId’ cannot be null
  •  New-AzureRmWebApp : ‘this.SubscriptionId’ cannot be null

Leave a Comment