azure-cli: az deployment randomly crashes with: ERROR: 'bytes' object has no attribute 'get'

Describe the bug when Running az deployments in github runners (azure-cli v2.28.0) it randomly crashes with ERROR: ‘bytes’ object has no attribute ‘get’. When in debug i also get the following error description:

DEBUG: cli.azure.cli.core.sdk.policies: Response content: DEBUG: cli.azure.cli.core.sdk.policies: “error”:“code”:“InternalServerError”,“message”:“Encountered internal server error. Diagnostic information: timestamp ‘20210929T131134Z’, subscription id ‘’, tracking id ‘xxxxxxxxxxxxxx’, request correlation id ‘xxxxxxxxxxxxxxxxxxx’.”*** DEBUG: cli.azure.cli.core.sdk.policies: Request URL: ‘https://management.azure.com/providers/Microsoft.Management/managementGroups/ESD-ConnectedS/providers/Microsoft.Resources/deployments/xxxxxxxxxxxxxxxea?api-version=2021-04-01

python errors: … custom.py", line 407, in on_requestAttributeError: ‘bytes’ object has no attribute ‘get’ … in handle_template_based_exceptionknack.util.CLIError: ‘bytes’ object has no attribute ‘get’ … ERROR: az_command_data_logger: ‘bytes’ object has no attribute ‘get’ DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03FF4460>]

To Reproduce az deployment sub create --subscription 'xxxxxxxxxxxxxxxxxxxx' --name (new-guid).guid --location westeurope –template-file ‘…\main.bicep’ --parameters ‘…\myparams.parameters.json’ --debug `

Expected behavior No errors

Environment summary az { “azure-cli”: “2.28.0”, “azure-cli-core”: “2.28.0”, “azure-cli-telemetry”: “1.0.6”, “extensions”: {} } ‘User-Agent’: ‘AZURECLI/2.28.0 (MSI) azsdk-python-azure-mgmt-resource/19.0.0 Python/3.8.9 (Windows-10-10.0.17763-SP0) GITHUBACTIONS_AzurePowerShellAction_175xxxxxxxxxxxxxxxx6bdb0dd’

also I am using bicep, not arm!

Additional context Have tried downgrading github runner az version to azure-cli v2.27.2 with same result, also the same error happens on local vm with same conf

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 22 (15 by maintainers)

Most upvoted comments

Template file (main.json):

{
    "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
        "_generator": {
            "name": "bicep",
            "version": "dev",
            "templateHash": "6486513756060996114"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Resources/resourceGroups",
            "apiVersion": "2019-05-01",
            "name": "rg-bicep",
            "location": "eastus",
            "resources": [
                null
            ]
        }
    ]
}

Command to repro:

az deployment sub validate --location westus --template-file main.json

@zhoxing-ms, note - there’s only a limited amount of time this will be repro-able with this template file. We have a fix checked in for the server-side cause of this particular issue, which will probably be deployed over the next few weeks.

@anthony-c-martin OK, we will have the plan to fix the CLI error handling