Azure CLI List All Resources

In this comprehensive article, I will walk you through the professional ways for using the az resource list command. I’ll show you how to filter like a professional, format your output for executive reports, etc.

Azure CLI List All Resources

Prerequisites

Before we start querying your infrastructure, ensure your local environment is ready. I recommend using the latest version of Azure CLI to ensure all resource providers are supported.

1. Installation and Login

Whether you are on a MacBook Pro or a Windows workstation, ensure you are logged in:

Bash

az login

2. Setting Your Context

Many organizations use a “Multi-Subscription” model (e.g., separate subscriptions for Development, Staging, and Production). You must ensure your CLI is pointing to the right environment.

Bash

# List all subscriptions available to you
az account list --output table

# Set your active subscription
az account set --subscription "Production-Internal-App-US-East"

After executing the above query, I got the expected output as shown in the screenshot below.

azure cli list all resources in subscription
list all resources azure cli

The Core Command: az resource list

The fundamental command we are exploring today is az resource list. By itself, this command is broad, acting as a global search for everything within your current subscription.

Basic Syntax

Bash

az resource list

After executing the query above, I received the expected output, as shown in the screenshot below.

azure cli list resources

When you run this without parameters, Azure returns a massive JSON array of every resource you have permission to view. This includes everything from Virtual Machines and Storage Accounts to Network Interfaces and Public IP addresses.

Understanding the JSON Output

Each resource returned contains a standard set of properties:

  • Name: The identifier of the resource.
  • Type: The resource provider namespace (e.g., Microsoft.Compute/virtualMachines).
  • Location: The Azure region (e.g., eastus or westus2).
  • Id: The full Resource Manager ID.
  • Tags: Any metadata associated with the resource.

Mastering the --output Parameter

As a seasoned architect, I rarely look at raw JSON unless I’m debugging a script. To make the data readable for your team in New York City or Philadelphia, you need to change the output format.

The Table Format

Bash

az resource list --output table

After executing the query above, I received the expected output, as shown in the screenshot below.

Azure CLI List All Resources

The TSV and CSV Formats

If you need to move this data into Excel for a budget meeting in Washington D.C., use the Tab-Separated Value (TSV) format.

Bash

az resource list --output tsv

After executing the query above, I received the expected output, as shown in the screenshot below.