Azure CLI Queries and Bash Pipe

Length: 00:13:26

Lesson Summary:

In this lesson we look at ways to retrieve, filter, and transform the output of Azure CLI. We do this using the Bash pipeline and Azure CLI queries.

Both of these tools provide an invaluable method for interacting with our resources through Azure CLI. For example, if we need to know the current date or look up resources, we can easily do so.

New and important commands used this lesson:

  • Piping list output for easier access: az group list | less
  • Searching the list output for text: az group list | grep "text"
  • Cutting the first field of output from a searched list: az group list -o tsv | grep "text" | cut -f1
  • JMESPath - querying the ID field: az group show -n name --query id
  • JMESPath - filtering based on a field: az group list --query "[?fieldToSearch=='valueToFind']"
  • JMESPath - filtering, selecting, and displaying specific fields: az group list --query "[?fieldToSearch=='valueToFind'].{displayName:fieldName,displayName2:fieldName2}" -o table

All commands used if you wish to follow along:

# Note you can use / key to search
az group list -o json | less
az group list -o tsv
az group list -o tsv | grep "hammeroftruth"
az group list -o tsv | grep "hammeroftruth" | cut -f1
az group show -n hammeroftruth-rg --query id
az group show -n hammeroftruth-rg --query properties.provisioningState
az group list --query "[?location=='australiasoutheast']"
az group list --query "[?location=='australiasoutheast'].{Name:RGName,ID:id}" -o table


This lesson is only available to Linux Academy members.

Sign Up To View This Lesson
Or Log In

Looking For Team Training?

Learn More