This Azure tutorial will discuss how to fix the error ‘this.Client.SubscriptionId’ cannot be null which I got while working with multiple PowerShell commands.
Table of Contents
‘this.client.subscriptionid’ cannot be null.
The above error came while executing 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 
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
I also got the error “New-AzureRmAppServicePlan: ‘this.Client.SubscriptionId’ cannot be null”. This 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 
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
This is mostly the permission issue. You need at least the Contributor access.
I also got the error “New-AzureRmWebApp: ‘this.SubscriptionId’ cannot be null”. This 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 
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
‘this.client.subscriptionid’ cannot be null. [Solved]
To fix all the above three issues, New-AzureRmResourceGroup: ‘this.Client.SubscriptionId’ cannot be null, New-AzureRmAppServicePlan : ‘this.Client.SubscriptionId’ cannot be null, New-AzureRmWebApp : ‘this.SubscriptionId’ cannot be null, we need to add the below cmdlets to the script
Get-AzureRmSubscription
Select-AzureRmSubscription -SubscriptionId xxxx4300-yyyy-xx18-9c9c-feaa72a5cbd1To get your subscriptionId, Login to the Azure portal and then search for the Subscription

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

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 
Note: Verify your subscription is ASM or ARM. Here, in this case your Azure subscription should be ARM.
If you have only an ASM subscription, you must add the ARM subscription.
This will fix all these above three errors.
Sometimes, while trying to remove any of your existing resources from your tenant, you might get the below error.
Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null
You might get the error Get-AzResourceGroup: ‘this.Client.SubscriptionId’ cannot be null while executing the Azure PowerShell cmdlet Get-AzResourceGroup.
Get-AzResourceGroupAfter executing the above Azure PowerShell cmdlet, you might have got the error Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null
Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null [Solved]
To fix the error,
The most important thing is to check if you have the proper permission for the Azure subscription or if you have created any Service Principal if that has proper permission for your Azure subscription.
This is how to fix the error Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.
You may like the following Azure tutorials:
- How to Connect to Azure in PowerShell (And Azure AD)
- Azure.psm1 cannot be loaded because running scripts is disabled on this system
In this Azure tutorial, we discussed how to fix the error ‘this.Client.SubscriptionId’ cannot be null which I got while working with multiple PowerShell commands.
I am Bijay, a Microsoft MVP (10 times) having more than 17 years of experience in the software industry. During my IT career, I got a chance to share my expertise in SharePoint and Microsoft Azure, like Azure VM, Azure Active Directory, Azure PowerShell, etc. I hope you will learn from these Azure tutorials. Read more
