-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
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