azure cli list subscriptions

Azure CLI: Mastering Subscription List using the Powerful Command

By James Young
AD

The Azure CLI (Command Line Interface) is a powerful tool for interacting with Azure services, including managing and listing subscriptions. If you're an Azure user, knowing how to list subscriptions using the Azure CLI can greatly streamline your workflow. Let's dive into this crucial task.

Before we proceed, ensure you've installed the Azure CLI and configured it with your credentials. Once set up, you can manage your Azure resources seamlessly from your terminal or command prompt.

Understanding Azure Subscriptions

A subscription in Azure is a container for billing and is the basis for access control and other subscription-level services. Understanding your subscriptions is key to managing your Azure resources effectively.

AD
Azure CLI Cheat Sheet — Resource Groups & VM Reference
Azure CLI Cheat Sheet — Resource Groups & VM Reference
Upsell a subscription
Upsell a subscription
a family tree is shown with several different types of items in the same area, including two
a family tree is shown with several different types of items in the same area, including two

In this guide, we'll explore how to list Azure subscriptions using the Azure CLI, helping you get a clear overview of your Azure resources.

Listing All Azure Subscriptions

The most basic way to list your Azure subscriptions is using the `az account list` command. This command returns a list of all subscriptions associated with your Azure account.

GitHub - Azure-Samples/azure-cli-samples: Contains Azure CLI scripts samples used for documentation at https://docs.microsoft.com
GitHub - Azure-Samples/azure-cli-samples: Contains Azure CLI scripts samples used for documentation at https://docs.microsoft.com
an image of a computer screen with the word azure in blue and green on it
an image of a computer screen with the word azure in blue and green on it
a flow diagram with several different types of logos and numbers on the same page, including two
a flow diagram with several different types of logos and numbers on the same page, including two

Here's the syntax: `az account list`. The command line will return a list in JSON format, displaying columns for `id`, `name`, `state`, and `subscriptionId`.

Filtering Subscription List

While the `az account list` command is excellent for getting an overview, sometimes you need more specific information. For instance, you might want to list only active subscriptions. To do this, you can use the `az account list --filter` option.

AD

Here's the syntax: `az account list --filter "[?state eq 'Enabled']"`. This command will return only the actively used subscriptions.

Igor Iric on LinkedIn: #azure #datamanagement #analytics #databricks #cloudarchitecture #cloud…
Igor Iric on LinkedIn: #azure #datamanagement #analytics #databricks #cloudarchitecture #cloud…
Azure Basics Explained Simply ☁️ | Microsoft Azure Cloud Services
Azure Basics Explained Simply ☁️ | Microsoft Azure Cloud Services
Microsoft Strategy Teardown
Microsoft Strategy Teardown
a blue and white poster with the words azure cli commands on it's side
a blue and white poster with the words azure cli commands on it's side
the azure cloud mindmap diagram
the azure cloud mindmap diagram
Azure Kubernetes Service (AKS) vs Google Kubernetes Engine (GKE)
Azure Kubernetes Service (AKS) vs Google Kubernetes Engine (GKE)

Switching Between Azure Subscriptions

Once you've listed your subscriptions, you might need to switch between them. The `az account set` command lets you switch to a specific subscription.

Here's the syntax: `az account set --subscription `. Replace `` with the name of the subscription you want to switch to.

AD

Setting the Default Subscription

If you frequently use a specific subscription, it's useful to set it as the default. This way, you don't need to specify the subscription each time you run a command.

the azure cloud service sheet is shown in this graphic, it shows different types of services
the azure cloud service sheet is shown in this graphic, it shows different types of services
Trying to Understand Azure. Notes from My Learning Journey So Far.
Trying to Understand Azure. Notes from My Learning Journey So Far.
Enable your Azure subscription for Data Lake Store - Part One
Enable your Azure subscription for Data Lake Store - Part One
a poster with some notes on it that say azure clustering and how to use them
a poster with some notes on it that say azure clustering and how to use them
Choose an Azure Compute Service - Azure Architecture Center
Choose an Azure Compute Service - Azure Architecture Center
Working With Azure Log Analytics Service
Working With Azure Log Analytics Service
the aws and azure comparison chart is shown in this graphic, which shows how many different
the aws and azure comparison chart is shown in this graphic, which shows how many different
Configuring Budget Alert In Azure
Configuring Budget Alert In Azure
Azure Integration Services for Business Modernization
Azure Integration Services for Business Modernization
Top Azure Consulting Companies 2026
Top Azure Consulting Companies 2026
the azure roadmap is shown in blue and white, with several different logos on it
the azure roadmap is shown in blue and white, with several different logos on it

Here's how you do it: `az account set --default `. Replace `` with the name of the subscription you want to set as default.

Removing an Azure Subscription

To remove an Azure subscription that you no longer need, you can use the `az account subscription delete` command.

AD

Here's the syntax: `az account subscription delete --name `. Be careful with this command, as deleting a subscription also deletes all resources within it.

That's it! You've now mastered the art of listing, switching, and managing Azure subscriptions using the Azure CLI. This skill will significantly enhance your Azure management capabilities. Happy coding!

AD