Patterson
Patterson

Reputation: 2823

How to list ALL resources in an Azure Subscription

Can someone let me know how go about obtaining all the resources within an Azure Subscription. I tried the following:

az resource list

The above just spewed out a lot of JSON that didn't really make any sense.

Upvotes: 0

Views: 697

Answers (2)

Rui Jarimba
Rui Jarimba

Reputation: 18179

The Azure CLI uses JSON as its default output format, but offers other formats, including (but not limited to):

  • table: ASCII table with keys as column headings
  • tsv: Tab-separated values, with no keys
  • yaml: YAML, a human-readable alternative to JSON

Use the --output (--out or -o) parameter to format CLI output.

Example

Get the names of the resources in a subscription:

az resource list –query "[].name" -o tsv --subscription NAME_OR_ID

Example output:

DemoVM010
demovm212
KBDemo001VM
KBDemo020

Upvotes: 1

Yash Tamakuwala
Yash Tamakuwala

Reputation: 2066

The JSON that it spewed out is a JSON Array that gives information about each resource in a JSON object such as location, resource group, tags, sku (if applicable), id, created and changed time and more. I think you might only want name and resource type in which case you can add query to that command like -

az resource list --query "[].{Name:name, Type:type}" --output table

Upvotes: 2

Related Questions