Azure subscription validation with Ansible

Copper Contributor

I would like to verify if an azure subscription exists using ansible.  I tried using az account show -s {{sub}} but it fails with an error rather than returning that the "subscription doesn't exist message". 


How to handle this gracefully?



1 Reply
It is solved with jq. Thanks!

az account list | jq '.[] | select(.name == "{{sub_name}}")|.name'