I am trying to write an azure cli JMESPath query to output all names which contain the word db and is of osType windows.
For this I have written the following query which works by calling the external bash utility called grep.
But I am unable to get it done with filtering in JMESPath language built in function contains.
Here is a query that works
az vm list --query "[?storageProfile.osDisk.osType=='Windows'].[name]" -o tsv | grep db
Here is a query that I tried and fails to get results:
az vm list --query "[?storageProfile.osDisk.osType=='Windows'].[?contains(name,'db')]" -o tsv
You just have to use an and expression:
Given the query:
On the JSON
This would give: