Describe the bug
az account list provides json output with a lot of subscriptions. one of the subscription has isDefault: true set. i am not able to query the id of the subscription which has isDefault: true set.
non working version with the azure cli:
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
we now use jq as a workaround, working version with jq:
az account list | jq -r '.[] | select(.name | startswith("Visual Studio Enterprise Subscription –")) | select(.isDefault == true) | [.id] | @TSV'
Related command
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
Errors
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
does not return the subscription id where isDefault is set to true
Issue script & Debug output
cli.knack.cli: Command arguments: ['account', 'list', '--debug', '--query', "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]", '-o', 'tsv']
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 0x104f77100>, <function OutputProducer.on_global_arguments at 0x105234180>, <function CLIQuery.on_global_arguments at 0x105255940>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: profile 0.001 2 8
cli.azure.cli.core: resource 0.064 52 232
cli.azure.cli.core: Total (2) 0.065 54 240
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 53 groups, 240 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : account list
cli.azure.cli.core: Command table: account list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x10678bc40>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/xxx/.azure/commands/2025-05-05.12-12-16.account_list.64321.log'.
az_command_data_logger: command args: account list --debug --query {} -o {}
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x1067e3240>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x1067e32e0>, <function register_cache_arguments..add_cache_arguments at 0x1067e3420>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x1067e34c0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x105234220>, <function CLIQuery.handle_query_parameter at 0x1052559e0>, <function register_ids_argument..parse_ids_arguments at 0x1067e3380>]
cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x1067e0540>, <function _x509_from_base64_to_hex_transform at 0x1067e05e0>]
cli.knack.cli: Event: CommandInvoker.OnFilterResult [<function CLIQuery.handle_query_parameter..filter_output at 0x106e90180>]
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x10678bec0>]
az_command_data_logger: exit code: 0
cli.main: Command ran in 0.149 seconds (init: 0.079, invoke: 0.071)
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 3851 in cache file under /Users/xxx/.azure/telemetry/20250505121216706
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.71.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.71.0/libexec/lib/python3.12/site-packages/azure/cli/telemetry/init.py /Users/xxx/.azure /Users/xxx/.azure/telemetry/20250505121216706"
telemetry.process: Return from creating process 64326
telemetry.main: Finish creating telemetry upload process.
Expected behavior
should show the subscription id where isDefault is set to true
Environment Summary
azure-cli 2.71.0
core 2.71.0
telemetry 1.1.0
Extensions:
azure-devops 1.0.1
Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1
Python location '/opt/homebrew/Cellar/azure-cli/2.71.0/libexec/bin/python'
Config directory '/Users/xxx/.azure'
Extensions directory '/Users/xxx/.azure/cliextensions'
Python (Darwin) 3.12.10 (main, Apr 8 2025, 11:35:47) [Clang 16.0.0 (clang-1600.0.26.6)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response
Describe the bug
az account list provides json output with a lot of subscriptions. one of the subscription has isDefault: true set. i am not able to query the id of the subscription which has isDefault: true set.
non working version with the azure cli:
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
we now use jq as a workaround, working version with jq:
az account list | jq -r '.[] | select(.name | startswith("Visual Studio Enterprise Subscription –")) | select(.isDefault == true) | [.id] | @TSV'
Related command
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
Errors
az account list --query "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]" -o tsv
does not return the subscription id where isDefault is set to true
Issue script & Debug output
cli.knack.cli: Command arguments: ['account', 'list', '--debug', '--query', "[?starts_with(name, 'Visual Studio Enterprise Subscription –') && isDefault == true].[id]", '-o', 'tsv']
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 0x104f77100>, <function OutputProducer.on_global_arguments at 0x105234180>, <function CLIQuery.on_global_arguments at 0x105255940>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'account': ['azure.cli.command_modules.profile', 'azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: profile 0.001 2 8
cli.azure.cli.core: resource 0.064 52 232
cli.azure.cli.core: Total (2) 0.065 54 240
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 53 groups, 240 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : account list
cli.azure.cli.core: Command table: account list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x10678bc40>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/xxx/.azure/commands/2025-05-05.12-12-16.account_list.64321.log'.
az_command_data_logger: command args: account list --debug --query {} -o {}
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x1067e3240>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x1067e32e0>, <function register_cache_arguments..add_cache_arguments at 0x1067e3420>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x1067e34c0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x105234220>, <function CLIQuery.handle_query_parameter at 0x1052559e0>, <function register_ids_argument..parse_ids_arguments at 0x1067e3380>]
cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x1067e0540>, <function _x509_from_base64_to_hex_transform at 0x1067e05e0>]
cli.knack.cli: Event: CommandInvoker.OnFilterResult [<function CLIQuery.handle_query_parameter..filter_output at 0x106e90180>]
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x10678bec0>]
az_command_data_logger: exit code: 0
cli.main: Command ran in 0.149 seconds (init: 0.079, invoke: 0.071)
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 3851 in cache file under /Users/xxx/.azure/telemetry/20250505121216706
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.71.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.71.0/libexec/lib/python3.12/site-packages/azure/cli/telemetry/init.py /Users/xxx/.azure /Users/xxx/.azure/telemetry/20250505121216706"
telemetry.process: Return from creating process 64326
telemetry.main: Finish creating telemetry upload process.
Expected behavior
should show the subscription id where isDefault is set to true
Environment Summary
azure-cli 2.71.0
core 2.71.0
telemetry 1.1.0
Extensions:
azure-devops 1.0.1
Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1
Python location '/opt/homebrew/Cellar/azure-cli/2.71.0/libexec/bin/python'
Config directory '/Users/xxx/.azure'
Extensions directory '/Users/xxx/.azure/cliextensions'
Python (Darwin) 3.12.10 (main, Apr 8 2025, 11:35:47) [Clang 16.0.0 (clang-1600.0.26.6)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response