azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Deploy Bicep template returns error "The content for this response was already consumed"

Open jason-dou opened this issue 5 months ago • 21 comments
trafficstars

Describe the bug

When deploying a Bicep template containing Microsoft.Graph resources, the response returns the error "The content for this response was already consumed". The expected behavior is to show the error message. The unexpected behavior also applies to deploying other Azure resources like managed identity.

Related command

az deployment group create --resource-group <resource-group> --template-file main.bicep

main.bicep

extension microsoftGraphV1

resource resourceApp 'Microsoft.Graph/[email protected]' existing = {
  uniqueNam: 'ExampleResourceApp'
}

output app object = resourceApp

bicepconfig.json

{
    "experimentalFeaturesEnabled": {
        "extensibility": true
    },
    "extensions": {
      "microsoftGraphV1": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:0.2.0-preview"
    }
}

Errors

The command returns unexpected error "The content for this response was already consumed"

Issue script & Debug output

cli.knack.cli: Command arguments: ['deployment', 'group', 'create', '--resource-group', '<resource-group>', '--template-file', 'main.bicep', '--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 0x01404A78>, <function OutputProducer.on_global_arguments at 0x01642668>, <function CLIQuery.on_global_arguments at 0x01662168>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'deployment': ['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: resource                  0.639        52       232
cli.azure.cli.core: Total (1)                 0.639        52       232
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 52 groups, 232 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : deployment group create
cli.azure.cli.core: Command table: deployment group create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x035ECF28>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\<user>\.azure\commands\2025-05-29.14-28-37.deployment_group_create.41368.log'.
az_command_data_logger: command args: deployment group create --resource-group {} --template-file {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x0360FAC8>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x036507F8>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x03650758>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x03650848>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x016426B8>, <function CLIQuery.handle_query_parameter at 0x016621B8>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x036507A8>]
cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false.
cli.azure.cli.command_modules.resource._bicep: Bicep CLI installation path: C:\Users\<user>\.azure\bin\bicep.exe
cli.azure.cli.command_modules.resource._bicep: Bicep CLI installed: True.
cli.azure.cli.command_modules.resource._bicep: WARNING: The following experimental Bicep features have been enabled: Extensibility. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.
Warning BCP035: The specified "resource" declaration is missing the following required properties: "uniqueName". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues. [https://aka.ms/bicep/core-diagnostics#BCP035]
Warning BCP089: The property "uniqueNam" is not allowed on objects of type "Microsoft.Graph/applications". Did you mean "uniqueName"? [https://aka.ms/bicep/core-diagnostics#BCP089]

cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ResourceManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\\Users\\<user>\\.azure\\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\<user>\.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74
msal.authority: openid_config("https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/2d2f744a-64f6-4d8b-af38-e43d35ee4e74/kerberos', 'tenant_region_scope': 'NA', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? True
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token_info: scopes=('https://management.core.windows.net//.default',), options={}
cli.azure.cli.core.auth.msal_credentials: UserCredential.acquire_token: scopes=['https://management.core.windows.net//.default'], claims_challenge=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 120b915b-af54-435f-b068-229a30af662d
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/b24b5122-ed51-497e-94f7-406bf93e7bfc/resourcegroups/<resource-group>/providers/Microsoft.Resources/deployments/main/validate?api-version=2022-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'POST'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies:     'Content-Length': '1380'
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': 'e1b7f51d-3cd3-11f0-b53b-4c034f865fbe'
cli.azure.cli.core.sdk.policies:     'CommandName': 'deployment group create'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '--resource-group --template-file --debug'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.73.0 (MSI) azsdk-python-core/1.31.0 Python/3.12.8 (Windows-11-10.0.26100-SP0)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"properties": {"template": "{\n  \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n  \"languageVersion\": \"2.1-experimental\",\n  \"contentVersion\": \"1.0.0.0\",\n  \"metadata\": {\n    \"_EXPERIMENTAL_WARNING\": \"This template uses ARM features that are experimental. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.\",\n    \"_EXPERIMENTAL_FEATURES_ENABLED\": [\n      \"Extensibility\"\n    ],\n    \"_generator\": {\n      \"name\": \"bicep\",\n      \"version\": \"0.35.1.17967\",\n      \"templateHash\": \"272145868128128081\"\n    }\n  },\n  \"imports\": {\n    \"microsoftGraphV1\": {\n      \"provider\": \"MicrosoftGraph\",\n      \"version\": \"0.2.0-preview\"\n    }\n  },\n  \"resources\": {\n    \"resourceApp\": {\n      \"existing\": true,\n      \"import\": \"microsoftGraphV1\",\n      \"type\": \"Microsoft.Graph/[email protected]\",\n      \"properties\": {\n        \"uniqueNam\": \"ExampleResourceApp\"\n      }\n    }\n  },\n  \"outputs\": {\n    \"app\": {\n      \"type\": \"object\",\n      \"value\": \"[reference('resourceApp')]\"\n    }\n  }\n}", "parameters": {}, "mode": "Incremental"}}
cli.azure.cli.command_modules.resource.custom: HTTP content is being overwritten to preserve template whitepace accurately. The request body logging may not accurately represent this.
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "POST /subscriptions/b24b5122-ed51-497e-94f7-406bf93e7bfc/resourcegroups/<resource-group>/providers/Microsoft.Resources/deployments/main/validate?api-version=2022-09-01 HTTP/1.1" 400 387
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '387'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'x-ms-failure-cause': 'gateway'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-writes': '199'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '3d3ebf0e-69c6-4b0f-8507-ec47eba30767'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '3d3ebf0e-69c6-4b0f-8507-ec47eba30767'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'SOUTHCENTRALUS:20250529T212843Z:3d3ebf0e-69c6-4b0f-8507-ec47eba30767'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies:     'X-MSEdge-Ref': 'Ref A: 459F39C77C064175A8C8532EED555C8D Ref B: SN4AA2022305045 Ref C: 2025-05-29T21:28:41Z'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 29 May 2025 21:28:42 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: Body is streamable
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/polling/base_polling.py", line 606, in initialize
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/polling/base_polling.py", line 156, in _raise_if_bad_http_status_and_method
azure.core.polling.base_polling.BadStatus: Invalid return status 400 for 'POST' operation

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 649, in _deploy_arm_template_at_resource_group
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/resource/resources/v2022_09_01/operations/_operations.py", line 7438, in begin_validate
  File "typing.py", line 1184, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/polling/_poller.py", line 164, in __init__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/core/polling/base_polling.py", line 611, in initialize
azure.core.exceptions.HttpResponseError: (InvalidTemplateDeployment) The template deployment 'main' is not valid according to the validation procedure. The tracking id is '3d3ebf0e-69c6-4b0f-8507-ec47eba30767'. See inner errors for details.
Code: InvalidTemplateDeployment
Message: The template deployment 'main' is not valid according to the validation procedure. The tracking id is '3d3ebf0e-69c6-4b0f-8507-ec47eba30767'. See inner errors for details.
Exception Details:      (BadRequest) Property 'uniqueName' should be non-empty string in resource 'applications'.
        Code: BadRequest
        Message: Property 'uniqueName' should be non-empty string in resource 'applications'.
        Target: /resources/resourceApp

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, 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/resource/custom.py", line 606, in deploy_arm_template_at_resource_group
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 651, in _deploy_arm_template_at_resource_group
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_utils.py", line 90, in _build_http_response_error_message
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/models.py", line 926, in text
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\requests/models.py", line 897, in content
RuntimeError: The content for this response was already consumed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 109, in handle_template_based_exception
AttributeError: 'RuntimeError' object has no attribute 'inner_exception'

During handling of the above exception, another exception occurred:

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 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, 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 726, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 114, in handle_template_based_exception
knack.util.CLIError: The content for this response was already consumed

cli.azure.cli.core.azclierror: The content for this response was already consumed
az_command_data_logger: The content for this response was already consumed
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x035EF0C8>]

Expected behavior

Response should display the error and the inner error message

Environment Summary

azure-cli 2.73.0

core 2.73.0 telemetry 1.1.0

Extensions: azure-devops 1.0.1

Dependencies: msal 1.32.3 azure-mgmt-resource 23.3.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'

Python (Windows) 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:07:15) [MSC v.1942 32 bit (Intel)]

Additional context

No response

jason-dou avatar May 29 '25 21:05 jason-dou

Thank you for opening this issue, we will look into it.

yonzhan avatar May 29 '25 21:05 yonzhan

Same issue still exists. Trying to do excercises , whenever I try to deploy from the same bicep template, I get this error. Seems to have to do with some cached info.

Update: my bad. I forgot to make the new resource group default like this:

az configure --defaults group="learn-ce5570b9-34be-4094-ad36-51d42a1564ae"

In this situation I switched to a new sandbox where the new resourcegroup of course had changed. Hope this helps others trying likewise....

mybesttools avatar Jun 01 '25 06:06 mybesttools

Same here, doing a super basic bicep intro tutorial on pluralsight, and immediately bump into this one.

davyvanlaere avatar Jun 01 '25 07:06 davyvanlaere

Always comes down to having the correct resource group selected:

Image

Also, when a new sandbox has spun up, it takes some time for things to settle...

mybesttools avatar Jun 01 '25 07:06 mybesttools

I started getting this as well once I updated to version 0.36.1 and I'm deploying to a management group scope so I don't think setting a default resource group makes a difference for me

sebassem avatar Jun 01 '25 07:06 sebassem

@sebassem Maybe you need to explicitly scope to that Management Group by defining 'scope'?

mybesttools avatar Jun 01 '25 07:06 mybesttools

Yeah I already have that, the template was working 10 minutes ago just before I upgraded Bicep

sebassem avatar Jun 01 '25 07:06 sebassem

My erroneous config:

azure-cli 2.73.0 core 2.73.0 telemetry 1.1.0 Dependencies: msal 1.32.3 azure-mgmt-resource 23.3.0

Downgraded (de-/reinstalled) to 2.72.0 : Problem gone! Getting only expected error outputs. Bug verified.

winget install --exact --id Microsoft.AzureCLI --version 2.72.0

Replay with any ARM template deployment. Start with an empty template. Add resources, retry deployment and get the error....

mybesttools avatar Jun 01 '25 08:06 mybesttools

We are seeing this error when we are deploying a template with invalid input such as missing values in a complex bicep param. It makes it impossible to debug what we are actually doing wrong.

rouke-broersma avatar Jun 02 '25 15:06 rouke-broersma

We are seeing this error when we are deploying a template with invalid input such as missing values in a complex bicep param. It makes it impossible to debug what we are actually doing wrong.

Same here. There used to be an error, which told you which params are missing or are too much. Now this error is quite useless.

Can you bring back the old error?

alesrosina avatar Jun 03 '25 08:06 alesrosina

Try using what-if rather than create, that still seems to show the deployment errors, allowing you to fix then and then deploy for real.

perfectphase avatar Jun 04 '25 23:06 perfectphase

This is definitely a bug. It doesn’t show normal errors on both az deployment group validate/create command. The way I forced it to show the error was to add “—debug” argument to the command.

alenroki avatar Jun 05 '25 06:06 alenroki

My work around was to add a task to revert back to Azure Cli version 2.72.0:

- task: Bash@3
  displayName: Uninstall Azure CLI and install specific version
  inputs:
    targetType: 'inline'
    script: |
  
      brew uninstall azure-cli
      pip3 install azure-cli==2.72.0 

Now getting all errors as normal.

marktyson avatar Jun 05 '25 13:06 marktyson

@marktyson I also thought about doing this. Thx for the tip and exact script.

alenroki avatar Jun 05 '25 13:06 alenroki

@marktyson same here... I just revert to an older version and it's working fine as it was

lturmel avatar Jun 07 '25 17:06 lturmel

+1, downgrading via shell and pip to 2.72.0 in GitHub Actions fixed this problem. Now I can see the actual errors I need to see. :)

FWIW, I also created this Issue: https://github.com/actions/runner-images/issues/12361

boldandbusted avatar Jun 10 '25 18:06 boldandbusted

version 2.74.0 doesn't seems to resolve this issue...

ayuina avatar Jun 13 '25 03:06 ayuina

The issue is still open.

srinadhbh avatar Jun 17 '25 17:06 srinadhbh

Try using what-if rather than create, that still seems to show the deployment errors, allowing you to fix then and then deploy for real.

This was helpful in my case. I'm using ARM Templates and not Bicep though.

After running with what-if, I got this errorr:

PreflightValidationCheckFailed - Preflight validation failed. Please refer to the details for the specific errors.
StorageAccountAlreadyTaken - The storage account named <storage_account_name> is already taken.

Likewise, I changed name and displayName for storage account resource and ran deploy with what-if until I got a success message.

It seems my name and displayName wasn't unique enough.

brysonbw avatar Jun 18 '25 16:06 brysonbw

I also run in this issue. The problem is in arm.py, line 109. It tries to read the ex.inner_expection, but there is no inner_exception property. Therefore a new exception gets thrown. The full path of the file is /src/azure-cli-core/azure/cli/core/commands/arm.py

Here is the relevant part of the log:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 109, in handle_template_based_exception
AttributeError: 'RuntimeError' object has no attribute 'inner_exception'

During handling of the above exception, another exception occurred:

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 666, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, 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 726, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 114, in handle_template_based_exception
knack.util.CLIError: The content for this response was already consumed

@yonzhan Probably related to this one: #27774

wilfriedb avatar Jun 19 '25 06:06 wilfriedb

Hey everyone,

I recommend using what-if check before running the actual deployment command itself.

We also had the same problem during one of our deployment pipelines to Azure, and the validation step gave the exact same error message.

Right after the validation step, we have what-if check - which is an additional check that gives more verbose error messages, and because of that, we were able to identify the underlying problem, which was related with one of our bicep templates.

An example command would be:

az deployment group what-if --resource-group testrg --name rollout01 --template-file main.bicep --parameters params.json

I hope that this would solve your problem too.

tunacinsoy avatar Jun 19 '25 14:06 tunacinsoy

I just want to point out that this same error happens on sub deployments too, which you can't specify a resource group, or management group, or subscription for. Subscription being the thing that would correlate with the recommendations here.

Rolling back azcli to 2.72 works and gives proper errors to figure out what to do

krallsm avatar Jun 24 '25 15:06 krallsm

I have the same error on version 2.74.0. Downgrading to 2.72 started showing the underlying error.

bahadirsemih avatar Jun 27 '25 10:06 bahadirsemih

A downgrade to 2.72 didn't help either, but running the command with --debug gave me an idea.

till avatar Jun 30 '25 14:06 till

I was facing this issue in CI and hence I tried running the commands from AZ CLI locally by downgrading the CLI version to 2.72 and it worked! thanks :)

ImPacific avatar Jul 04 '25 13:07 ImPacific

Bump. Was az deploying yesterday with 2.75 and faced this issue. Had to go back to 2.72

Az Cli team, would be reassuring going forward to know that you're testing some az deployments designed to fail to ensure they produce the expected output before marking a build as a release.

bedalus avatar Jul 07 '25 09:07 bedalus

@jason-dou @yonzhan Can we get an update on this issue? This is 3 releases now that this has been broken and there's been no updates. This should've been rolled back if it hasn't been able to be fixed yet.

krallsm avatar Jul 08 '25 13:07 krallsm

@shenglol @alex-frankel can you check is this bicep or CLI related?

miqm avatar Jul 08 '25 15:07 miqm

Issue #31709 is tracking the same problem with a more technical explanation.

I ran into the same problem and incorporated @msyyc's suggestion into #31684 which has now been merged, so I expect this'll be fixed in the next release of Azure CLI. Until then, I don't think there's a workaround other than downgrading your version of Azure CLI.

@msyyc - could you confirm when the next AzureCLI release will be?

anthony-c-martin avatar Jul 08 '25 15:07 anthony-c-martin

@anthony-c-martin The next Azure CLI version will be released on 08-05

zhoxing-ms avatar Jul 09 '25 03:07 zhoxing-ms