This is a working solution but not very clean:
if [ "$(az vm list -d -o table --query "[?name=='VM_NAME']")" == "$(az vm list -d -o table --query "[?name=='ABSURD_NAME_THAT_CERTAINLY_DOES_NOT_EXIST']")" ];
then
printf "VM DOES NOT EXIST YET"
else
printf "VM ALREADY EXISTS"
fi
I couldn't figure out, what
"$(az vm list -d -o table --query "[?name=='ABSURD_NAME_THAT_CERTAINLY_DOES_NOT_EXIST']")"
returns which is why I couldn't shorten this solution.
I'm certainly no expert in Bash scripting and I don't know how to convert the result to hexvalues or similar to make it visible.
So I am looking for either a short version of this solution or for another more clean approach. Unfortunately, I couldn't find anything like az vm exists.