Describe the bug
I want to get the name of a public IP address using the --query parameter to find a specific tag. The command only works if the tag key does not contain a dash ( - ).
Related command
not working:
az network public-ip list --query "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name" -o tsv
working:
az network public-ip list --query "[?tags.abc=='ingress-basic/ingress-nginx-controller'].name" -o tsv
Errors
argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
Issue script & Debug output
cli.knack.cli: Command arguments: ['network', 'public-ip', 'list', '--query', "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name", '-o', 'tsv', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x01CCA4A8>, <function OutputProducer.on_global_arguments at 0x01ECD6E8>, <function CLIQuery.on_global_arguments at 0x01EE8340>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: network 0.296 115 458
cli.azure.cli.core: privatedns 0.010 14 63
cli.azure.cli.core: Total (2) 0.305 129 521
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 128 groups, 521 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : network public-ip list
cli.azure.cli.core: Command table: network public-ip list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0413B4F0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\Wolfgang.azure\commands\2024-01-01.23-04-35.network_public-ip_list.9108.log'.
az_command_data_logger: command args: network public-ip list --query {} -o {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x04163658>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x041745C8>, <function register_cache_arguments..add_cache_arguments at 0x041747C0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443
urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22network+public-ip+list%22%2C+%22parameters%22%3A+%22--output%2C--query%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.51.0%22%2C+%22errorType%22%3A+%22InvalidJMESPathQuery%22%2C+%22correlationId%22%3A+%229846897d-b5ab-4cf1-939e-fa6c94921260%22%2C+%22subscriptionId%22%3A+%22e347e896-c1d2-4aea-b63d-2c7f5f6acc7e%22%2C+%22eventId%22%3A+%22b9e8fa81-3c21-4cae-bd8d-d49754bf534c%22%7D HTTP/1.1" 200 None
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "argparse.py", line 2488, in _get_value
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/query.py", line 24, in jmespath_type
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/init.py", line 8, in compile
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 88, in parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 96, in _do_parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 109, in _parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/lexer.py", line 78, in tokenize
jmespath.exceptions.LexerError: Bad jmespath expression: Unknown token '-':
[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "argparse.py", line 1859, in parse_known_args
File "argparse.py", line 2072, in _parse_known_args
File "argparse.py", line 2012, in consume_optional
File "argparse.py", line 1920, in take_action
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 272, in _get_values
File "argparse.py", line 2455, in _get_values
File "argparse.py", line 2501, in _get_value
argparse.ArgumentError: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
cli.azure.cli.core.azclierror: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
az_command_data_logger: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0413B610>]
az_command_data_logger: exit code: 2
cli.main: Command ran in 0.795 seconds (init: 0.196, invoke: 0.599)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3588 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry_init_.pyc C:\Users\Wolfgang.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
Expected behavior
The command finds the IP address with the specified tag and returns its name. Escaping the dash ( - ) with backticks ( ` ) did not work.
Environment Summary
azure-cli 2.55.0
core 2.55.0
telemetry 1.1.0
Additional context
No response
Describe the bug
I want to get the name of a public IP address using the --query parameter to find a specific tag. The command only works if the tag key does not contain a dash ( - ).
Related command
not working:
az network public-ip list --query "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name" -o tsv
working:
az network public-ip list --query "[?tags.abc=='ingress-basic/ingress-nginx-controller'].name" -o tsv
Errors
argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
Issue script & Debug output
cli.knack.cli: Command arguments: ['network', 'public-ip', 'list', '--query', "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name", '-o', 'tsv', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x01CCA4A8>, <function OutputProducer.on_global_arguments at 0x01ECD6E8>, <function CLIQuery.on_global_arguments at 0x01EE8340>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'network': ['azure.cli.command_modules.network', 'azure.cli.command_modules.privatedns']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: network 0.296 115 458
cli.azure.cli.core: privatedns 0.010 14 63
cli.azure.cli.core: Total (2) 0.305 129 521
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 128 groups, 521 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : network public-ip list
cli.azure.cli.core: Command table: network public-ip list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x0413B4F0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\Wolfgang.azure\commands\2024-01-01.23-04-35.network_public-ip_list.9108.log'.
az_command_data_logger: command args: network public-ip list --query {} -o {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x04163658>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x041745C8>, <function register_cache_arguments..add_cache_arguments at 0x041747C0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
urllib3.connectionpool: Starting new HTTPS connection (1): app.aladdin.microsoft.com:443
urllib3.connectionpool: https://app.aladdin.microsoft.com:443 "GET /api/v1.0/suggestions?query=%7B%22command%22%3A+%22network+public-ip+list%22%2C+%22parameters%22%3A+%22--output%2C--query%22%7D&clientType=AzureCli&context=%7B%22versionNumber%22%3A+%222.51.0%22%2C+%22errorType%22%3A+%22InvalidJMESPathQuery%22%2C+%22correlationId%22%3A+%229846897d-b5ab-4cf1-939e-fa6c94921260%22%2C+%22subscriptionId%22%3A+%22e347e896-c1d2-4aea-b63d-2c7f5f6acc7e%22%2C+%22eventId%22%3A+%22b9e8fa81-3c21-4cae-bd8d-d49754bf534c%22%7D HTTP/1.1" 200 None
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "argparse.py", line 2488, in _get_value
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/query.py", line 24, in jmespath_type
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/init.py", line 8, in compile
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 88, in parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 96, in _do_parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/parser.py", line 109, in _parse
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\jmespath/lexer.py", line 78, in tokenize
jmespath.exceptions.LexerError: Bad jmespath expression: Unknown token '-':
[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "argparse.py", line 1859, in parse_known_args
File "argparse.py", line 2072, in _parse_known_args
File "argparse.py", line 2012, in consume_optional
File "argparse.py", line 1920, in take_action
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/parser.py", line 272, in _get_values
File "argparse.py", line 2455, in _get_values
File "argparse.py", line 2501, in _get_value
argparse.ArgumentError: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
cli.azure.cli.core.azclierror: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
az_command_data_logger: argument --query: invalid jmespath_type value: "[?tags.k8s-azure-service=='ingress-basic/ingress-nginx-controller'].name"
To learn more about --query, please visit: 'https://docs.microsoft.com/cli/azure/query-azure-cli'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0413B610>]
az_command_data_logger: exit code: 2
cli.main: Command ran in 0.795 seconds (init: 0.196, invoke: 0.599)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3588 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry_init_.pyc C:\Users\Wolfgang.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
Expected behavior
The command finds the IP address with the specified tag and returns its name. Escaping the dash ( - ) with backticks ( ` ) did not work.
Environment Summary
azure-cli 2.55.0
core 2.55.0
telemetry 1.1.0
Additional context
No response