‘this.client.subscriptionid’ cannot be null.

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.

‘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 
'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

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

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 
'this.client.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

‘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-feaa72a5cbd1

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

you are using the set-azurermvmsourceimage command with the -version parameter. you wish to ensure that you get the most current image. which value should you use with the -version parameter?

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

'this.client.subscriptionid' cannot be null

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 
you are using the set-azurermvmsourceimage command with the -version parameter. you want to ensure you get the most current image. which value should you use with the -version parameter?

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-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 how to fix the error Get-AzResourceGroup : ‘this.Client.SubscriptionId’ cannot be null.

You may like the following Azure tutorials:

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.