azure-clijmespath

JMESPath extract raw values from list


I'm trying to do some scripting with the Azure CLI. Say that my query is returning the following:

[
  "a",
  "b",
  "c"
]

I want to use these values in a bash loop. It would be much nicer to get them in the following form:

a
b
c

Is there a way to do that with, ideally, JMESPath query primitives? Otherwise I'll have to use bash commands which leaves a lot to be desired from JMESPath.


Solution

  • It seems that you could use --out tsv,

    For example, az vm list --out tsv | grep RGD | cut -f8

    KBDemo001VM
    KBDemo020
    

    More details from https://learn.microsoft.com/en-us/cli/azure/format-output-azure-cli?view=azure-cli-latest#tsv-output-format