Azure / Azure/azure-cli

az containerapp --yaml fails parsing to json when user assigned identity is included

Open
#23,307 6 comments 0 reactions 0 assignees View on GitHub
act-observability-squad Auto-Assign Container Instances ContainerApp customer-reported question Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62

**Related command**
`az containerapp create -n container-name -g resource-group --yaml file.yaml`

**Describe the bug**
Using the yaml specification for creating a containerapp, when user assigned identities are specified, it will always say:
`The 'UserAssignedIdentities' property keys should only be empty json objects, null or the resource exisiting property.` (actually the response also has a typo `exisiting` 😄 )

Upon checking running again with `--verbose` on, it seems the empty json object `{}`, still get parsed to json as:
```
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"managed-identity-id": {
"principalId": null,
"clientId": null
}
},
"principalId": null,
"tenantId": null
}
```

I understand that the use of `identity` in the yaml specification isn't actually listed in the [documentation](https://docs.microsoft.com/en-gb/azure/container-apps/azure-resource-manager-api-spec?tabs=yaml#container-app-examples), but it seems that it is possible to use it, just that the parsing of empty `{}` values in yaml creates those null `principalId` and `clientId` properties.

**To Reproduce**
1. Create a managed identity (managed-identity)
2. Have a yaml specification file (file.yaml) ready, but also include:
```
identity:
type: UserAssigned
userAssignedIdentities:
managed-identity-id: {}
```
3. Have a resource group ready (example-rg)
4. Run: `az containerapp create -n container-name -g example-rg --yaml file.yaml`

**Expected behavior**
I'd expect the container app to be created with the managed identity assigned to the ACA

**Environment summary**
My az version: `2.38.0`

**Additional context**

After finding checking out the request body via `--verbose`, I've tried it myself via [rest ](https://docs.microsoft.com/en-gb/rest/api/containerapps/container-apps/create-or-update?), and changing the identity value to empty json works.
i.e
```
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"managed-identity-id": {}
},
"principalId": null,
"tenantId": null
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.