az deployment [sub|group] create returns invalid JSON on error
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**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
``` bicep
// 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
```json
{'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
Contributor guide
Assessment
This issue has not been assessed yet.