Support agent principal types in role assignments - #33810
Open
jruttle wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c68fc8b-b668-4d31-bff0-292712a310b2
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the role command module to support Azure RBAC agent principal types by (1) allowing AgentUser / AgentServicePrincipal for az role assignment create --assignee-principal-type, and (2) preserving those types when resolving assignees via Microsoft Graph lookups.
Changes:
- Added
RoleAssignmentPrincipalTypeenum (including agent principal types) and wired it intorole assignment createargument parsing. - Extended Microsoft Graph
@odata.type→ ARM RBACprincipalTypemapping for agent objects and used it when resolving assignees by UPN/SPN. - Added unit tests covering the new enum values and resolution behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role_custom.py | Adds tests validating agent principal type enum values and Graph-based resolution behavior. |
| src/azure-cli/azure/cli/command_modules/role/custom.py | Adds agent principal type constants/mapping and preserves principal type based on Graph @odata.type during assignee resolution. |
| src/azure-cli/azure/cli/command_modules/role/_params.py | Introduces a shared RoleAssignmentPrincipalType enum and uses it for --assignee-principal-type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
381
to
384
| # A temporary fix for https://github.com/Azure/azure-cli/issues/11594 | ||
| # As only 'User', 'Group' or 'ServicePrincipal' are allowed values, the REST spec contains invalid values | ||
| # (like MSI) which are used only internally by the service. So hide them. | ||
| # https://github.com/Azure/azure-rest-api-specs/blob/962013a1cf9bf5b87e3aad75a14c7dd620acda62/specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-04-01-preview/authorization-RoleAssignmentsCalls.json#L508-L522 |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation —⚠️ Review suggested
Summary
AgentUserandAgentServicePrincipalforaz role assignment create --assignee-principal-typeagentUserandagentIdentityobjects to the matching Azure RBAC principal typesTesting
python -m unittest azure.cli.command_modules.role.tests.latest.test_role_customThe values are part of the stable
2022-04-01Authorization contract after Azure/azure-rest-api-specs#44846.