If a tag on a resource has a name that includes a -
the query fails incorrectly.
To Reproduce
CREATED-BY
to a resource group in Azure with a value of 'foobar'az group list -o tsv --query "[?tags.CREATED-BY == 'foobar']"
Expected behavior
Normally the results will show the item.
Actual result
The error shows as
az group list: error: argument --query: invalid jmespath_type value: "[?tags.CREATED-BY == 'foobar']"
If you run a similar query on http://jmespath.org/ as below, it works fine
locations[?state == 'WA' && foo-bar == 'foobar'].name | sort(@)
Using data of:
{
"locations": [
{"name": "Seattssle", "state": "WA", "foo-bar": "foobar"},
{"name": "New York", "state": "NY"},
{"name": "Bellevue", "state": "WA"},
{"name": "Olympia", "state": "WA"}
]
}
Environment summary
This is verified to fail in the Azure Cloud Shell.
Additional context
Add any other context about the problem here.
same here :-(
Sorry for running into such troubles, but Jemspath requires the property be a valid identifier unless you wrap them with quotes . Because of the -
, CREATED-BY
is not a right id, so please wrap it.
(env) D:\sdk\azure-cli>az group list -o tsv --query "[?tags.\"CREATED-BY\" == 'yugangw']"
/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/yg4 westus None yg4
@tjprescott, @williexu, I am closing this, but if we receive more such confusions, we need to document of how to use jmespath.
JFYI, the grammar syntax is here
Most helpful comment
Sorry for running into such troubles, but Jemspath requires the property be a valid identifier unless you wrap them with quotes . Because of the
-
,CREATED-BY
is not a right id, so please wrap it.@tjprescott, @williexu, I am closing this, but if we receive more such confusions, we need to document of how to use jmespath.