Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Microsoft Azure PowerShell cmdlet 'this.Client.SubscriptionId' cannot be null

While working on one of my expired and disabled Microsoft Azure subscription with PowerShell, I was receiving error (Get-AzVirtualNetwork: 'this.Client.SubscriptionId' cannot be null) when trying to get information from Azure Virtual Network. Although I was receiving error for all the resources when getting information. Below are the two commands tried first.

Connect-AzAccount
Get-AzVirtualNetwork

Next to resolve this issue get the list of Azure subscription. In the followed command use one of the subscription name which you want to connect and set it as context in Az Powershell.

Get-AzSubscription
Get-AzSubscription -SubscriptionName <Your subscription name> | Set-AzContext

Microsoft Azure PowerShell Connect-AzAccount Get-AzVirtualNetwork Get-AzSubscription TenantId Subscription Set-Azcontext azurecloud environment automation.png

Once subscription is set as context (Sets the tenant, subscription, and environment for cmdlets to use in the current session), I am able to fetch Virtual Network information without any error.

Microsoft azure Get-AzVirtualNetwork resource group powershell vwan tags subnets subscription az cmdlets virtual network peering.png

Useful Articles
Create a Virtual machine on Microsoft Azure
PowerShell List All Azure Resverations
Powershell get the list of Azure Reservations Virtual Machines instances
Get the list Azure Reservation Catalog with PowerShell and AzureCLI
Azure automation account DSC for On-Premise Virtual Machine on boarding
Azure Powershell : Operation returned an invalid status code 'BadRequest'
Create an Azure Automation account on using Portal PowerShell and AzureCLI
Get Azure virtual machine backup reports using Powershell
Why is my Azure recovery services vault not getting deleted?

Go Back

Comment

Blog Search

Page Views

7476756

Follow me on Blogarama