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

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

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

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 [Solved]

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 [Solved]

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 that are 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-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
error: ‘subscriptionid’ cannot be null

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.

Error: ‘subscriptionid’ cannot be null

Sometimes, while you are trying to remove any of your existing resources from your tenant, you might get the below error.

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

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

The complete error message is like below

Remove-AzureRmResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.
At line:1 char:1
+ Remove-AzureRmResourceGroup -name DemoRG
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : CloseError: (:) [Remove-AzureRmResourceGroup], ValidationException
     + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.RemoveAzureResourceGroupCmdlet

Error: ‘subscriptionid’ cannot be null [Solved]

If you receive this error when you try to remove your existing resources from your Tenent, Then you have to check the Azure subscription status.

Now, what you need to do is, You have to check the Azure Subscription status using the below Azure PowerShell cmdlet.

Get-AzureRmContext

Remove-AzureRmResourceGroup : ‘this.Client.SubscriptionId’ cannot be null [Solved]

To fix, this issue you can set the Azure Subscription manually by running the below Azure PowerShell cmdlet

 Select-AzureRmSubscription

The complete script is like below

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

Make sure to update the SubscriptionId based on yours.

This is how you can able to fix the error Remove-AzureRmResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.

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

Some times, while creating the Azure Resource Group using the New-AzResourceGroup Azure PowerShell cmdlet, you might get the below error

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

After running the below PowerShell script, I got the error

New-AzResourceGroup -Name Demo1RG -Location 'westus'

The error I got was New-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.

New-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null [Solved]

To fix the error, You need to set the Azure Subscription for creating any Azure resources without the Azure subscription.

You can select the list of Azure Subscriptions using the Get-AzSubscription Azure PowerShell cmdlet.

Azure Error - This.Client.SubscriptionId' cannot be null
Azure Error – This.Client.SubscriptionId’ cannot be null

The next step is to set the Azure Subscription using the below PowerShell cmdlet

Select-AzSubscription {subscription id}
Select-AzSubscription -SubscriptionId xxxx4300-yyyy-xx18-9c9c-feaa72a5cbd1

Make sure to replace the Azure SubscriptionId with yours.

This is how you can able to fix the error New-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.

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-AzResourceGroup

After 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 mostly the permission issue, you need at least the Contributor access.

This is how to fix the error Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.

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
  • Error: ‘subscriptionid’ cannot be null
  • Remove-AzureRmResourceGroup : ‘this.Client.SubscriptionId’ cannot be null
  • New-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null
  • Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null