Forum Discussion

space3's avatar
space3
Copper Contributor
Jan 17, 2021

Azure subscription validation with Ansible

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?

 

Thanks,
RK

  • space3's avatar
    space3
    Copper Contributor
    It is solved with jq. Thanks!

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

Resources