How to Find the Current Azure Subscription using Azure PowerShell

Table of Contents

Connect to Microsoft Azure PowerShell

First, you need connect to Microsoft Azure PowerShell, there’re two ways to run PowerShell commands in Microsoft Azure:

Method 1: From Azure PowerShell modules installed in a computer.

How to Find the Current Azure Subscription using Azure PowerShell

Method 2: From Azure Cloud Shell using browsers.

How to Find the Current Azure Subscription using Azure PowerShell

Gets Azure subscriptions in Azure account

The Get-AzureSubscription cmdlet gets the subscriptions in your Azure account. You can use this cmdlet to get information about the subscriptions.

In some cases, your account has multiple active subscriptions, and you need to determine which one is set to current.

Get-AzSubscription

Name           Id                                   TenantId                         
----           --                                   --------                             
Visual Studio  3e05a8c7-a93f-4987-8b60-a1cbdf484858 615dc844-35d3-40c2-9db4-xxxxxxxxxxxxx
Visual Studio  3177f05d-9d74-4995-abf8-b7a971a2aaa1 615dc844-35d3-40c2-9db4-xxxxxxxxxxxxx
Visual Studio  b319d331-f43b-4347-903d-b8aa158a3195 615dc844-35d3-40c2-9db4-xxxxxxxxxxxxx
Visual Studio  633c1a7c-95b3-4b76-a18b-94e73cd12665 615dc844-35d3-40c2-9db4-xxxxxxxxxxxxx 

To check the current subscription that are currently set in your account, let’s run the following command:

(Get-AzContext).Subscription

Name           Id                                   TenantId                             State
----           --                                   --------                             -----
Visual Studio  a0099b9b-b15f-4a1e-b1b6-017214605980 615dc844-35d3-40c2-xxxxxxxxxxxxxxxxx Enabled

Switch or change between subscriptions

If you want to switch to another subscription, let’s run the following command:

Set-AzContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"

Leave a Comment

Required fields are marked *