Show Current Active Azure Subscription and Manage Access

Author

Reads 158

Young man intensely focused on computer work in a tech office setting with a whiteboard in the background.
Credit: pexels.com, Young man intensely focused on computer work in a tech office setting with a whiteboard in the background.

To view your current active Azure subscription, you can check the Azure portal.

The Azure portal is where you can manage all your Azure resources, including your subscriptions.

To access the Azure portal, simply navigate to portal.azure.com in your web browser.

Once you're logged in, click on the profile picture or icon in the top right corner and select "Subscriptions" from the dropdown menu.

Managing Azure Subscriptions

To manage your Azure Subscriptions, you first need to know the details of your subscriptions, such as the id or name.

The az account list command will return a JSON output containing information about all your Azure Subscriptions, including the tenantId of Azure AD, the user you're logged in with, and the cloudName.

You can see the JSON output contains a few different values, but only the name and id are necessary for verifying and setting which Azure Subscription you want to run Azure CLI commands against.

Engineer fixing core swith in data center room
Credit: pexels.com, Engineer fixing core swith in data center room

To list all your Azure Subscriptions, run the az account list command in the terminal.

Once you know which Azure Subscription you need to scope the Azure CLI context to, you will set the Azure CLI to use that subscription with the az account set command.

Be sure to replace the placeholders in the command with the actual id or name for the Azure Subscription you wish to target.

If the az account set command executed successfully, the terminal will not return a response, so it's essential to run the az account show command afterwards to verify the Azure CLI is set to the correct subscription.

If there is an error setting the Azure CLI to a specific subscription, an error message will be returned, indicating that the specified subscription does not exist.

Changing Subscription Settings

You can change the active subscription in Azure using the az account set command, specifying the desired subscription ID or name.

Credit: youtube.com, Subscriptions Microsoft Azure-- Adding subscription to account

To switch to a different subscription, you'll need to know its ID or name, which can be found in the Azure portal.

If you're changing to a subscription in a different tenant, you'll also be changing the active tenant.

To add a new subscription to your Microsoft Entra tenant, see the instructions on Associate or add an Azure subscription to your Microsoft Entra tenant.

If you encounter a "The subscription of ... doesn't exist..." error, check the Troubleshooting section for possible solutions.

For more insights, see: Create Tenant Azure

Set Subscription Target

To set the Azure CLI to use a specific subscription, you'll need to run the az account set command. This command allows you to explicitly tell the Azure CLI which subscription you want to target.

You can set the Azure CLI to use a subscription by specifying its ID or name. For example, if you want to set the Azure CLI to use a subscription with the ID '12345678-1234-1234-1234-123456789012', you would run the command: az account set --subscription '12345678-1234-1234-1234-123456789012'.

Credit: youtube.com, 6_Microsoft Azure Subscription Dashboard Lab| HandOn|Multiple Subscription in a Tenant

Alternatively, you can set the Azure CLI to use a subscription by specifying its name. If you want to set the Azure CLI to use a subscription with the name 'My Subscription', you would run the command: az account set --subscription 'My Subscription'.

To verify that the Azure CLI is set to the correct subscription, run the az account show command. This command will display a JSON response with information about the subscription the Azure CLI is currently set to work with.

If you receive an error message when trying to set the Azure CLI to a specific subscription, it may be because the subscription does not exist. In this case, you can try running the az account list command to see a list of all the subscriptions you have access to.

Consider reading: Azure Cli Set Subscription

Frequently Asked Questions

How do I see active services in Azure?

To view active services in Azure, sign in to the Azure portal and navigate to Service Health in the All services menu. This will provide you with information on services that are currently available for any subscription you have access to.

Leslie Larkin

Senior Writer

Leslie Larkin is a seasoned writer with a passion for crafting engaging content that informs and inspires her audience. With a keen eye for detail and a knack for storytelling, she has established herself as a trusted voice in the digital marketing space. Her expertise has been featured in various articles, including "Virginia Digital Marketing Experts," a series that showcases the latest trends and strategies in online marketing.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.