[dataprotection] Specify principal type for AKS backup roles - #10262
Conversation
Create managed-identity role assignments by object ID with an explicit ServicePrincipal type so PIM Only Mode does not depend on Microsoft Graph inference. Apply the same hardening to the AKS Web App Routing live test and publish dataprotection 1.11.4. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi FumingZhang, |
There was a problem hiding this comment.
Pull request overview
This PR hardens role-assignment helpers used by AKS backup enablement flows by explicitly using managed-identity object IDs and setting principalType=ServicePrincipal, avoiding Microsoft Graph inference (and related failures) in app-only / limited-directory-permissions environments.
Changes:
- Update AKS backup role-assignment checks/creates to use
assignee_object_idandassignee_principal_type="ServicePrincipal", including aligned manual remediation commands. - Strengthen unit and live-test coverage assertions around the new role-assignment invocation shape.
- Bump the Data Protection extension version to
1.11.4and add release notes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/dataprotection/setup.py | Bumps extension version to 1.11.4. |
| src/dataprotection/HISTORY.rst | Adds 1.11.4 release note describing the principal-type change. |
| src/dataprotection/azext_dataprotection/tests/latest/test_dataprotection_enable_backup.py | Updates unit tests to assert assignee_object_id + assignee_principal_type usage and improved error message matching. |
| src/dataprotection/azext_dataprotection/manual/aks/aks_helper.py | Uses assignee_object_id/ServicePrincipal when listing/creating role assignments; updates manual remediation command accordingly. |
| src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py | Hardens AKS web app routing live-test setup role assignment to use explicit object-id + principal-type flags. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Restore the aks-preview live test on this branch so the existing pull request remains scoped exclusively to the Data Protection extension. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the helper parameter and all callers so non-object assignee values are not mistaken for supported input, and document why the helper bypasses Graph lookup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Switch to persistent-resource subscriptions only during live runs so recorded tests can use the CI profile subscription instead of failing before cassette replay. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
dataprotection |
|
[Release] Update index.json for extension [ dataprotection-1.11.4 ] : https://dev.azure.com/msazure/One/_build/results?buildId=179101006&view=results |
🤖 PR Validation — ️✔️ All clear
Related command
az dataprotection enable-backup triggeraz aks create --enable-backup/az aks update --enable-backupDescription
AKS backup role-assignment helpers already receive managed-identity object IDs, but passed them through
assignee. Azure CLI then queries Microsoft Graph to infer the principal type. In app-only environments without Graph directory permissions, the GUID fallback leaves the type unset and omitsprincipalTypefrom the role-assignment request.This change:
assignee_object_idwith an explicitServicePrincipaltype when checking and creating AKS backup role assignments.Explicitly setting the type avoids Graph inference, reduces fresh-identity propagation failures, and keeps the requests compliant with PIM Only Mode enforcement.
The
aks-previewlive-test change originally included here was moved to #10263 so that the Data Protection product fix and AKS test fix can be reviewed independently.CI follow-up
The initial CI run exposed two existing recorded Data Protection scenarios that unconditionally switched to a live persistent-resource subscription. Playback profiles contain only the sanitized CI subscription, so all Python versions failed before cassette replay with:
The tests now switch subscriptions only during live runs. Recorded runs continue against the playback profile's subscription.
Validation
azdev style dataprotection --pep8 --pylintazdev test azext_dataprotection --series --no-exitfirst- 81 passed, 26 skippedpython scripts/ci/test_index.py -q- 9 passed, 2 skippedazdev extension build dataprotection- builtdataprotection-1.11.4-py3-none-any.whlgit diff --checkGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
Once merged, the normal release automation can publish Data Protection 1.11.4 and update
src/index.json; this PR intentionally does not edit the generated index.