Reputation: 2823
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
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 headingstsv
: Tab-separated values, with no keysyaml
: YAML, a human-readable alternative to JSONUse the --output
(--out
or -o
) parameter to format CLI output.
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
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