New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--ids
parameter does not work correctly with --query
#5591
Comments
Hello, nice to meet you. I also got a similar problem with yours with BTW, I guess that you mean |
Yes and yes. :) |
I am seeing the same thing with all of the commands using --ids, including az vm show and az vm get-instance-view. If there is more than one id provided then an array is returned, but JMESPATH queries are not handled correctly. E.g.
This will work for a single id, or for the first element in an array (or loop as tjprescott discussed. The rest of the JSON comes through unqueried. Outputting to a table looks even worse. And actually this should not work at all. If the query was applied to the whole array then the query should look like:
If you were looking to output an array of filtered objects. Arguably the --ids switch should always return an array, even if it has only one element - at least then scripting around it would be consistent. |
@richeney yes, the issue is with the |
If I run the following (admitted contrived) example, in which I want to get the names of my VNETs:
az network vnet show --ids $(az network vnet list -g {rg} --query [].id -o tsv) --query [].name
I get the following:
The query is only applied to the first item. Because
--ids
actually runs the command in a loop, I would actually need to use the following syntax:az vnet show --ids $(az vnet list -g {rg} --query [].id -o tsv) --query name
This syntax is not intuitive to the user who expects a list and thus would expect list-like query syntax. However, even then my results are still screwed up:
Because the query isn't applied in subsequent loops.
Environment summary
Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (
az --version
) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)The text was updated successfully, but these errors were encountered: