question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az version --query "azure-cli" should return version number and not throw error

See original GitHub issue

Describe the bug

When I run az version --query "azure-cli" it should return the version number: "2.4.0"

Command Name az version

Errors:

az version: error: argument --query: invalid jmespath_type value: "azure-cli"'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • az version --query "azure-cli"

Expected Behavior

According to the tutorial pages you suggest people use to learn about JMESPath, it should work like this:

image

I copied the output from a plain az version execution, and selected the field I wanted manually in the online tool.

I would expect az version --query "azure-cli" to perform the same logical function and return 2.4.0

Environment Summary

Windows-10-10.0.17134-SP0
Python 3.6.6
Installer: MSI

azure-cli 2.4.0

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
jiaslicommented, Apr 24, 2020

This is the design of JMESPath that - is parsed as minus. See https://github.com/jmespath/jmespath.py/issues/109#issuecomment-240315651.

So in the query azure-cli needs to be quoted as "azure-cli" as you did in the screenshot:

image

However, since the terminal interprets double quotes, the command needs to be escaped.

In Windows CMD:

>az version --query "\"azure-cli\""
"2.4.0"

In Windows PowerShell (Actually \ shouldn’t be necessary, but we need them here due to https://github.com/PowerShell/PowerShell/issues/1995):

> az version --query '\"azure-cli\"'
"2.4.0"
> az version --query "\`"azure-cli\`""
"2.4.0"

In Bash:

$ az version --query "\"azure-cli\""
"2.4.0"
$ az version --query '"azure-cli"'
"2.4.0"
0reactions
jiaslicommented, Apr 30, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tips for using the Azure CLI successfully - Microsoft Learn
Learn tips for using Azure CLI successfully, such as output formats, passing parameter values, and quoting rules for different shells.
Read more >
JMESPath query command results with Azure CLI
How to query Azure CLI command output using a JMESPath query ... to 'OsProfile' in the query above will not return the correct...
Read more >
Output formats for Azure CLI commands - Microsoft Learn
Learn how to format the output of Azure CLI commands to tables, lists or json. ... none, No output other than errors and...
Read more >
Release notes & updates – Azure CLI - Microsoft Learn
Learn about the latest Azure Command-Line Interface (CLI) release notes and updates for both the current and beta versions of the CLI.
Read more >
How to install the Azure CLI - Microsoft Learn
The current version of the Azure CLI is 2.43.0. For information about the latest release, see the release notes. To find your installed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found