Skip to content

az deployment [sub|group] create returns invalid JSON on error #22835

@wbreza

Description

@wbreza

Related command
az deployment group|sub create

Describe the bug
When executing a az deployment group|sub create command that has a deployment/provisioning error the error output returns INVALID JSON.

In version 2.28 error output was valid and contained double quoted attribute values. Latest version of the CLI returns single quoted JSON which is invalid can causes errors when parsing JSON.

To Reproduce
Any bicep/arm file that throws an error will be sufficient. This example uses a resource that is not available in the selected region

// main.bicep
resource web 'Microsoft.Web/staticSites@2021-03-01' = {
  name: 'mystaticwebapp'
  location: 'northcentralus'
  sku: {
    name: 'Free'
    tier: 'Free'
  }
  properties: {
    provider: 'Custom'
  }
}

Run the following command az deployment group create --template-file main.bicep --location northcentralus -g {resource_group}

Returns the following JSON like response

{'code': 'LocationNotAvailableForResourceType', 'message': "The provided location 'northcentralus' is not available for resource type 'Microsoft.Web/staticSites'. List of available regions for the re    esource type is 'westus2,centralus,eastus2,westeurope,eastasia,eastus2euap,centraluseuap'."}

Expected behavior
Command should fail but return VALID double quoted JSON

Environment summary
Install Method: MSI
OS: Windows 11
Shell type: Any

az version
{
  "azure-cli": "2.37.0",
  "azure-cli-core": "2.37.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "application-insights": "0.1.16",
    "azure-cli-iot-ext": "0.8.10",
    "resource-graph": "2.1.0"
  }
}

Additional context
Worked as expected in 2.28

Metadata

Metadata

Assignees

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by bot

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions