I am new to shell scripting. I am trying to use
az sig image-version list
command from azure which should return a list of versions and storing it into a list/array. So I can step through the list in a for loop.
VERSIONS_LIST="$(az sig image-version list --gallery-image-definition $GALLERY_IMAGE_NAME --gallery-name $GALLERY_NAME --resource-group $RESOURCE_GROUP_NAME)`"
However, I am not sure if the command returns more than just the versions. If so how can I only take part of the output?
I am also having issue with displaying the populated list. I believe my syntax of using the azure cli to store in the list is wrong. any guidance is much appreciated.
echo VERSION_LIST
Am I storing the list correctly into the variable?
You can use Global Parameters
--queryand--outputto query the version list with JMESPath from the output ofaz sig image-version listthen you can store the output as a variable in bash like this without double quotation marks,Then you can check the variable with command
echo $VERSIONS_LIST. If you want to run for loop, you may do it like this,For example, here is a bash script with CLI 2.0. See this blog for more details.
See bash for loop examples.