I am searching through Azure container and want to filter out blobs ending with certain suffixes. When I use the --query
parameter with a JMESPath contains
function, it is giving me an error.
When I run the command
az storage blob list
--account-name $account_name
--account-key $key
--num-results $numResults
--show-next-marker
--container-name $container_name
--query [].name
it runs without any error.
When I change the query to
--query [].name[?contains(@,'R00005006')=='true']
or
--query [].name[?contains(@,'R00005006')]
I get this error:
syntax error near unexpected token `(‘
2
Answers
You need to put the query in quotes for it to be parsed correctly by the command prompt as well as create a projection for it be properly parsed.
Take note that
true
is surrounded with a backtick.If you are looking for the whole blob object content, then you should have your condition on the array of blob objects:
So, in you Azure command:
If you are just looking for a list of names indeed, you have to stop the list projection created by
.name
with a pipe expression:So, in your Azure command: