skip to Main Content

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.

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search