Contents
I recently came across a new error I hadn’t seen before. It suddenly showed up during Bicep deployments that had previously been running just fine days or even weeks ago.
When Does This Error Occur?
The error appears to occur whenever a Bicep deployment fails, but only when triggered via Azure CLI. Deployments run through PowerShell don’t seem to be affected.
It also doesn’t matter what the actual cause of the failure is. It could be due to an Azure Policy blocking the deployment, or simply a wrong parameter value.
Root Cause
Here are a few observations based on my testing:
- The issue appears to have been introduced in Azure CLI version 2.73.0
- It doesn’t occur when running deployments via PowerShell
- The error is triggered as soon as a deployment failure happens, regardless of whether modules are used
- It seems to be related to how the actual error message is constructed inside Azure CLI
- The message doesn’t originate from the API itself, but from the
requestsPython library used internally in Azure CLI, which explains why the error is so generic and not particularly helpful
Here’s an example of the output when using the --debug flag:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/resource/custom.py", line 521, in deploy_arm_template_at_subscription_scope
return _deploy_arm_template_at_subscription_scope(cmd=cmd,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/resource/custom.py", line 560, in _deploy_arm_template_at_subscription_scope
err_message = _build_http_response_error_message(err)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/resource/_utils.py", line 90, in _build_http_response_error_message
error_txt = http_error.response.internal_response.text
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/requests/models.py", line 926, in text
if not self.content:
^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/requests/models.py", line 897, in content
raise RuntimeError("The content for this response was already consumed")
RuntimeError: The content for this response was already consumed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/arm.py", line 109, in handle_template_based_exception
raise CLIError(ex.inner_exception.error.message)
^^^^^^^^^^^^^^^^^^
AttributeError: 'RuntimeError' object has no attribute 'inner_exception'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
return cmd_copy.exception_handler(ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/arm.py", line 114, in handle_template_based_exception
raise CLIError(ex)
knack.util.CLIError: The content for this response was already consumed
Solution / Workaround
Use the –debug or –what-if flag
The easiest way to get more detailed error information is to run your deployment with the --debug or --what-if flag, e.g.:
az deployment sub create --location westeurope --template-file main.bicep --debug
This will output known error messages with clearer context, like this:
Code: InvalidTemplateDeployment
Message: The template deployment failed because of policy violation. Please see details for more information.
Exception Details: (RequestDisallowedByPolicy) Resource 'kv-ipypc6zd6mqek' was disallowed by policy. Policy identifiers: '[{"policyAssignment":{"name":"Azure Key Vault should disable public network access","id":"/subscriptions/{subscriptionId}/resourceGroups/rg-demo/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentId}"},"policyDefinition":{"name":"Azure Key Vault should disable public network access","id":"/providers/Microsoft.Authorization/policyDefinitions/405c5871-3e91-4644-8a63-58e19d68ff5b","version":"1.1.0"}}]'.
Code: RequestDisallowedByPolicy
Message: Resource 'kv-ipypc6zd6mqek' was disallowed by policy. Policy identifiers: '[{"policyAssignment":{"name":"Azure Key Vault should disable public network access","id":"/subscriptions/{subscriptionId}/resourceGroups/rg-demo/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentId}"},"policyDefinition":{"name":"Azure Key Vault should disable public network access","id":"/providers/Microsoft.Authorization/policyDefinitions/405c5871-3e91-4644-8a63-58e19d68ff5b","version":"1.1.0"}}]'.
Target: kv-ipypc6zd6mqek
Downgrade Azure CLI version to 2.72.0
It appears that this error was introduced in Azure CLI version 2.73.0. One possible workaround is to downgrade to version 2.72.0.
That’s about it – I hope this helps! Let’s see if this is just a temporary hiccup that gets fixed in a future release.

Sebastian
Any help how to downgrade?
Marco
The easiest way is to uninstall Azure CLI and reinstall it with the desired version. Check How to install the Azure CLI for the various OS and version flags.
Andy Steiner
Many thanks for your help, Marco! I just had the exact same issue and downgrading brought me a step further. In my case, the cpu quota has exceeded and 2.75.0 doesn’t seem to be able to handle this properly.
Marco
Hi Andy, happy to hear it helped and thank you for your feedback!
Ritesh
we are using Microsoft-hosted agent which is ubuntu-latest taking the latest version 2.75, still we are getting the same error
Marco
As far as I know, the issue hasn’t been resolved in the latest version. You might want to try setting the version to 2.72.0.
Moha
Ohh this was really bugging me recently. But it should only be around till 1st of July. Thank you for your post!
Marco
Glad I could help! Let’s hope it gets fixed soon.
Sunny
Downgrading the version resolved this for me. Thanks a ton for your help!
Marco
Awesome, glad it helped!