az cli incorrect parsing of query "--query "[0].keys(@)"
See original GitHub issueThis is autogenerated. Please review and update as needed.
Describe the bug
I get an error message (see below) when I issue the following command. The command should output the structure of the json data.
Command Name
az vm list -d --query "[0].keys(@)"
Errors:
az vm list: error: argument --query: invalid jmespath_type value: '[0].keys(@'
usage: az vm list [-h] [--verbose] [--debug] [--only-show-errors]
[--output {json,jsonc,yaml,yamlc,table,tsv,none}]
[--query JMESPATH] [--subscription _SUBSCRIPTION]
[--resource-group RESOURCE_GROUP_NAME] [--show-details]
To learn more about [--query JMESPATH] usage in AzureCLI, visit https://aka.ms/CLIQuery
C:\>echo Failed to load python executable.
Failed to load python executable.
C:\>exit /b 1
As you may notice in the error message the closing parenthesis of the query is missing. So I reissued the slightly modified command with an extra space after the closing parenthesis:
az vm list -d --query "[0].keys(@) "
Et Voilà:
[
"location",
"tags",
... skipped for prevety
"privateIps",
"macAddresses",
"resourceGroup"
]
To Reproduce:
See above.
Expected Behavior
The command should output the keys of the json describing the vm.
Environment Summary
Windows-10-10.0.19041-SP0
Python 3.6.8
Installer: MSI
azure-cli 2.11.0 *
Extensions:
interactive 0.4.4
Additional Context
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top Results From Across the Web
JMESPath query command results with Azure CLI
The Azure CLI uses the --query argument to execute a JMESPath query on the results of commands. Learn how to use the features...
Read more >AZ CLI and JMESPath queries
Here is one example that demonstrates how to check if the key vault exists and how to create it if it doesn't. Focus...
Read more >AZ CLI query filter on multiple properties using && - ...
I am trying to create an az cli query that can evaluate if I am logged into the correct tenant and subscription.
Read more >JMESPATH queries
The Azure CLI uses the industry standard JMESPATH query format that is used not only by the ... Here is some example JSON...
Read more >parse_url - Manual
parse_url(string $url , int $component = -1): int|string|array|null|false ... As of PHP 8.0.0, parse_url() distinguishes absent and empty queries and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At least now I have an idea why the variant with the extra space
az vm list --query "[0].keys(@) "
worked.I assumed any character would do, but the real difference seems to be that the whitespace prevents prevents PowerShell from stripping the quotes as mentioned in Quoting issues with PowerShell.
This is confirmed by the fact that the following variants of the command work as expected (in PowerShell):
Well - live and learn.
It is a service issue after my investigation.