Repository navigation
[ContainerApp] az containerapp update: Fix --yaml dropping identity.userAssignedIdentities - #34253
Conversation
…ity.userAssignedIdentities`
clean_null_values removed every empty dict, including the {} value of each
userAssignedIdentities entry, so the update-from-YAML PATCH carried only
identity.type and silently lost the declared user-assigned identities. Keep
those entries (still stripping null read-only fields inside them).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Thank you for your contribution bogdan.trifan (@bogdantrifan13)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix addresses the reported payload loss with targeted regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes az containerapp update --yaml dropping user-assigned identities during PATCH payload cleanup.
Changes:
- Preserves identity entries whose values are empty dictionaries while still removing null fields.
- Adds regression coverage for identity preservation and empty or null identity maps.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_utils.py | Adds identity cleanup regression tests. |
| src/azure-cli/azure/cli/command_modules/containerapp/_utils.py | Preserves user-assigned identity entries during cleanup. |
Review effort: Balanced
|
Hi bogdan.trifan (@bogdantrifan13), |
|
@microsoft-github-policy-service agree |
@microsoft-github-policy-service agree |
|
End-to-end verification against a real existing app (user-assigned identity used both as the app identity and as the registry pull identity), using azure-cli 2.86.0 +
Note for reviewers: the empty-dict stripping is long-standing (it predates #27078 and survived #28163), so this is not a recent CLI regression. The same CLI build deployed successfully until ~2026-10-20 20:00 UTC; since then the service rejects the identity-less PATCH, which is what surfaced it. 🤖 Generated with Claude Code |
Related command
az containerapp update --yamlDescription
az containerapp update --yamlsilently dropsidentity.userAssignedIdentitiesfrom the PATCH it sends. A manifest declaringis sent (per
--debug) as"identity": {"type": "UserAssigned"}.Cause: the update-from-YAML path runs the payload through
clean_null_values, which removes every empty dict. The value of each user-assigned identity entry is legitimately{}, so the entry is removed, and then the now-emptyuserAssignedIdentitiesmap is removed too:This affects
update_containerapp_yamlhere and thecontainerappextension'sContainerAppUpdateDecorator.set_up_update_containerapp_yaml, which imports the same function.az containerapp create --yamldoes not call it and is unaffected.The service now rejects that body for apps whose registry pull identity (
configuration.registries[].identity) is a user-assigned identity, with a misleading error whose "resource ID" is a NotFound body for the app itself:Every
update --yamlof such an app fails, whilecreate --yaml, or a direct PATCH of the same manifest with the identity intact, succeeds. Seen on azure-cli 2.86.0 and 2.91.0 withcontainerappextension 1.3.0b5.Change:
clean_null_valueskeeps the entries of auserAssignedIdentitiesmap (an identity's value cleans to{}, with null read-only fields such asprincipalId/clientIdstill stripped). An empty or nulluserAssignedIdentitiesis still removed, so all other behaviour is unchanged.Testing Guide
test_clean_null_values_keeps_user_assigned_identitiesincontainerapp/tests/latest/test_containerapp_utils.py: it fails on currentdevand passes with this change. The existing tests in the file still pass.az containerapp update -n <app> -g <rg> --yaml <manifest> --debug. The PATCH body now includesidentity.userAssignedIdentities.History Notes
[ContainerApp]
az containerapp update: Fix--yamldroppingidentity.userAssignedIdentities, which causedIdentityDoesNotExisterrorsThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.
🤖 Generated with Claude Code