Describe the bug
Hi all,
While investigating the following issue that I encountered with az consumption budget create: #29950
I came across a strange inconsistency in the way commands are parsed in the interactive CLI and the regular CLI. One commentor suggested a fix of using az rest and adjusting the body, and this kind of ended up fixing the issue.
Related command
The following command works in the interactive CLI but not the regular CLI. In the regular CLI, it throws an error (the az prefix is excluded in interactive mode).
az rest --method PUT --url 'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01' --body '{"properties":{"amount":10.0,"category":"cost","filter":{},"timeGrain":"monthly","timePeriod":{"endDate":"2027-01-01T05:00:00.000Z","startDate":"2026-06-01T04:00:00.000Z"}}}'
The error attached can be remedied if the user replaces all single quotes with double quotes and instead uses \" to escape double quotes within the command.
Errors
The command failed with an unexpected error. Here is the traceback:
No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 677, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 789, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 335, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 23, in rest_call
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1089, in send_raw_request
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 700, in send
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 795, in get_adapter
requests.exceptions.InvalidSchema: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
Based on the traceback, the error seems to stem from the fact that the --url parameter is not parsed properly in the regular CLI, thus leading to a URL submitted between single quotes to remain underneath single quotes.
Issue script & Debug output
Debug output of the command that only works in the interactive CLI:
cli.knack.cli: Command arguments: ['rest', '--method', 'PUT', '--url', "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'", '--body', "'{properties:{amount:10.0,category:cost,filter:{},timeGrain:monthly,timePeriod:{endDate:2027-01-01T05:00:00.000Z,startDate:2026-06-01T04:00:00.000Z}}}'", '--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 0x0165D528>, <function OutputProducer.on_global_arguments at 0x019A0618>, <function CLIQuery.on_global_arguments at 0x019C4898>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Using packaged command index for profile 'latest'.
cli.azure.cli.core: Found installed extension 'interactive' (azext_interactive).
cli.azure.cli.core: Modules found from index for 'rest': ['azure.cli.command_modules.util']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Loaded command modules in parallel:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: util 0.007 1 3
cli.azure.cli.core: Total (1) 0.011 1 3
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 1 groups, 3 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : rest
cli.azure.cli.core: Command table: rest
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x01B52258>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\gensk\.azure\commands\2026-06-05.03-57-31.rest.31196.log'.
az_command_data_logger: command args: rest --method {} --url {} --body {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x01B828E8>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x01B82938>, <function register_global_policy_argument.<locals>.add_global_policy_argument at 0x01B82CF8>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x01B82D48>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x01B82D98>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x019A0668>, <function CLIQuery.handle_query_parameter at 0x019C48E8>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x01B82CA8>]
cli.azure.cli.core.util: Request URL: "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
cli.azure.cli.core.util: Request method: 'PUT'
cli.azure.cli.core.util: Request headers:
cli.azure.cli.core.util: 'User-Agent': 'python/3.13.13 (Windows-11-10.0.26220-SP0) AZURECLI/2.87.0 (MSI)'
cli.azure.cli.core.util: 'Accept-Encoding': 'gzip, deflate'
cli.azure.cli.core.util: 'Accept': '*/*'
cli.azure.cli.core.util: 'Connection': 'keep-alive'
cli.azure.cli.core.util: 'x-ms-client-request-id': '9c0a5743-48a0-405a-b2ce-814e767bb196'
cli.azure.cli.core.util: 'Content-Type': 'application/json'
cli.azure.cli.core.util: 'CommandName': 'rest'
cli.azure.cli.core.util: 'ParameterSetName': '--method --url --body --debug'
cli.azure.cli.core.util: 'Content-Length': '151'
cli.azure.cli.core.util: Request body:
cli.azure.cli.core.util: "{properties:{amount:10.0,category:cost,filter:{},timeGrain:monthly,timePeriod:{endDate:2027-01-01T05:00:00.000Z,startDate:2026-06-01T04:00:00.000Z}}}"
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 677, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 789, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 335, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 23, in rest_call
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1089, in send_raw_request
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 700, in send
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 795, in get_adapter
requests.exceptions.InvalidSchema: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 677, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 789, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 335, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 23, in rest_call
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1089, in send_raw_request
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 700, in send
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 795, in get_adapter
requests.exceptions.InvalidSchema: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
az_command_data_logger: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 677, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 789, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 335, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 23, in rest_call
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 1089, in send_raw_request
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 700, in send
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/sessions.py", line 795, in get_adapter
requests.exceptions.InvalidSchema: No connection adapters were found for "'https://management.azure.com/subscriptions/2a62e50d-4f3d-432d-8627-5acbe1680c8c/providers/Microsoft.Consumption/budgets/monthlyBudget?api-version=2023-05-01'"
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x01B52398>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.133 seconds (init: 0.181, invoke: 0.952)
Expected behavior
Expected behavior is to create a budget, however the command throws an error in some instances.
Environment Summary
azure-cli 2.87.0
core 2.87.0
telemetry 1.1.0
Extensions:
interactive 1.0.0b1
Dependencies:
msal 1.36.0
azure-mgmt-resource 24.0.0
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\gensk.azure'
Extensions directory 'C:\Users\gensk.azure\cliextensions'
Python (Windows) 3.13.13 (tags/v3.13.13:01104ce, Apr 7 2026, 19:11:29) [MSC v.1944 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
There seems to be a number of similar bugs that stem from strange parsing between single and double quotes; in the regular CLI, another one I found during this process involved wrapping only the --url in double quotes but leaving the --body in single quotes (with double quotes inside for the json). This led to the api request body in debug mode appearing as being entirely wrapped in double quotes (as in, double quotes AROUND the json object) and also having stripped all of the double quotes from inside of the json (which somehow led to an authorization error...?). I'm unsure if these are all related to one single parsing issue, but one step at a time :)
Describe the bug
Hi all,
While investigating the following issue that I encountered with
az consumption budget create: #29950I came across a strange inconsistency in the way commands are parsed in the interactive CLI and the regular CLI. One commentor suggested a fix of using
az restand adjusting the body, and this kind of ended up fixing the issue.Related command
The following command works in the interactive CLI but not the regular CLI. In the regular CLI, it throws an error (the
azprefix is excluded in interactive mode).The error attached can be remedied if the user replaces all single quotes with double quotes and instead uses
\"to escape double quotes within the command.Errors
Based on the traceback, the error seems to stem from the fact that the
--urlparameter is not parsed properly in the regular CLI, thus leading to a URL submitted between single quotes to remain underneath single quotes.Issue script & Debug output
Debug output of the command that only works in the interactive CLI:
Expected behavior
Expected behavior is to create a budget, however the command throws an error in some instances.
Environment Summary
azure-cli 2.87.0
core 2.87.0
telemetry 1.1.0
Extensions:
interactive 1.0.0b1
Dependencies:
msal 1.36.0
azure-mgmt-resource 24.0.0
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\gensk.azure'
Extensions directory 'C:\Users\gensk.azure\cliextensions'
Python (Windows) 3.13.13 (tags/v3.13.13:01104ce, Apr 7 2026, 19:11:29) [MSC v.1944 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
There seems to be a number of similar bugs that stem from strange parsing between single and double quotes; in the regular CLI, another one I found during this process involved wrapping only the
--urlin double quotes but leaving the--bodyin single quotes (with double quotes inside for the json). This led to the api request body in debug mode appearing as being entirely wrapped in double quotes (as in, double quotes AROUND the json object) and also having stripped all of the double quotes from inside of the json (which somehow led to an authorization error...?). I'm unsure if these are all related to one single parsing issue, but one step at a time :)