Skip to content

[Compute] az vm/vmss identity assign: Avoid resending existing identities - #34433

Merged
JaysonTaiMicrosoft merged 10 commits into
Azure:devfrom
william051200:fix-vm-identity
Nov 26, 2026
Merged

JaysonTaiMicrosoft merged 10 commits into
Azure:devfrom
william051200:fix-vm-identity

Conversation

@william051200

@william051200 William (william051200) commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests Suppressions
️✔️ None ️✔️ 130/130 ️✔️ None

Related command

az vm/vmss identity assign

Description

Resolve #34422

Identity assignment resends every attached user-assigned identity, causing LinkedAuthorizationFailed when the caller can assign the requested identity but lacks assignment permission on unrelated existing identities.

Testing Guide

python -m pytest src\azure-cli\azure\cli\command_modules\vm\tests\latest\test_custom_vm_commands.py::TestIdentityAssignment
azdev test test_vm_identity_assign_preserves_existing_identities test_vmss_identity_assign_preserves_existing_identities --live

History Notes

[Compute] az vm/vmss identity assign: Fix unnecessary assignment-permission checks on existing user-assigned identities by submitting only requested identities


This checklist is used to make sure that common guidelines for a pull request are followed.

@william051200 William (william051200) added the Request X Engineering Agent Ask the agent to triage this issue or review this PR label Nov 16, 2026
Copilot AI balanced review requested due to automatic review settings November 16, 2026 07:45
@x-engineering-agent

x-engineering-agent Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

X Engineering Agent Pull request review: Comments

William (@william051200) No defect was confirmed in the inspected VM/VMSS identity-assignment paths. Upstream CI passed, but regression coverage for the restricted-caller scenario remains unverified by the available execution evidence.

Check Status Detail
Upstream CI Passed The handoff reports 52 completed, successful checks and no failures.
Agent live tests Not run This is a review-only PR.
Regression coverage Unverified For vm: 2 focused test file(s) and 7 recording file(s) changed.
Risk Risk 31/100 Medium Medium; owner review recommended
Review details

Upstream CI

The handoff reports 52 completed, successful checks and no failures.

Test validation

  • Agent live test: Not run; this is a review-only PR. Check author-provided test evidence and upstream CI separately.
  • Regression coverage: For vm: 2 focused test file(s) and 7 recording file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.

The inspected tests represent the intended conditions: the caller can write the compute resource and assign identity B, but cannot assign existing identity A. src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:6963–7036 checks rejection of explicit A assignment, successful B assignment, preservation of A+B, and unchanged A metadata for both VM and VMSS. test_custom_vm_commands.py:105–167 checks exact serialized identity maps, including system-only omission and combined identity types.

The request change sends only requested identities rather than resending existing ones. In src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vm_vmss_identity_assign_restricted_caller.yaml:2423–2478,2564–2584,3198–3253,3340–3360, A-only requests receive LinkedAuthorizationFailed, while B-only requests succeed. The inspected responses preserve A+B. Confirm execution of test_vm_vmss_identity_assign_restricted_caller against these restricted permissions for both commands, plus the identity payload tests, before treating scenario coverage as verified. Existing system-identity retention must also remain covered. These are author-provided test/recording artifacts, not an Agent live-test result.

Inspection limit: Production changes, planned test excerpts and the restricted-caller recording were inspected; full inspection of the six other changed recordings was not completed: test_sig_msi.yaml, test_vm_explicit_msi.yaml, test_vm_msi.yaml, test_vm_msi_no_scope.yaml, test_vmss_explicit_msi.yaml and test_vmss_msi.yaml, all under src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/. The independent runtime pass returned no usable assessment. No recording inconsistency was confirmed.

Risk assessment

31/100 · Medium

The Medium rating is driven by public CLI behavior.

  • Change scope: 12 changed files, 42334 changed lines (+16466 / -25868), including 3 production files.
  • Affected components: vm
  • Risk drivers: public CLI behavior (+18)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is recommended for vm before merge.

Ask the Agent

Tick a box to queue an action. Requires write access to this repository.

  • Re-review this PR
  • Run Agent live tests on this PR

X Engineering Agent · Reviewer · React with +1 or -1 to train the agent

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Inherited schema caching can bypass the extended VM and VMSS patch schemas, causing identity assignment to fail because identity_type is missing.

1 open issue
What changed in this PR

This PR addresses #34422 by making az vm/vmss identity assign submit only requested user-assigned identities, avoiding permission checks on unrelated identities already attached.

Changes:

  • Shares assignment-argument logic while preserving the existing identity type.
  • Extends VM and VMSS PATCH operations to retain combined identity types without resending existing identities.
  • Adds serialized-request unit tests and live preservation scenarios, and refreshes existing test configurations.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​vm/​tests/​latest/​test_vm_commands.py Adds live identity-preservation checks and updates scenario configurations.
src/​azure-cli/​azure/​cli/​command_modules/​vm/​tests/​latest/​test_custom_vm_commands.py Tests requested-only PATCH payloads and identity-type preservation.
src/​azure-cli/​azure/​cli/​command_modules/​vm/​operations/​vmss.py Adds an internal identity-type override for VMSS PATCH requests.
src/​azure-cli/​azure/​cli/​command_modules/​vm/​operations/​vm.py Adds an internal identity-type override for VM PATCH requests.
src/​azure-cli/​azure/​cli/​command_modules/​vm/​custom.py Centralizes assignment arguments and stops including untouched identities.

Review effort: Balanced



class VMPatch(_VMPatch):
@classmethod
x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Agent reviewed this PR label Nov 16, 2026
@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@x-engineering-agent x-engineering-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

William (@william051200) Please fix the CI failures first. Details are under Upstream CI in the review. See the X Engineering Agent Report.

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@JaysonTaiMicrosoft
JaysonTaiMicrosoft enabled auto-merge (squash) November 26, 2026 01:11
@JaysonTaiMicrosoft
JaysonTaiMicrosoft merged commit 8cceb0c into Azure:dev Nov 26, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Compute az vm/vmss/image/disk/snapshot Request X Engineering Agent Ask the agent to triage this issue or review this PR X Engineering Agent Reviewed Agent reviewed this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az vmss identity assign sends all existing user-assigned identities in the PATCH since 2.84.0, causing LinkedAuthorizationFailed

6 participants