[Role] Feature: Add az role deny-assignment create/delete commands#33109
Open
jruttle wants to merge 13 commits into
Open
[Role] Feature: Add az role deny-assignment create/delete commands#33109jruttle wants to merge 13 commits into
az role deny-assignment create/delete commands#33109jruttle wants to merge 13 commits into
Conversation
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.
DescriptionAdds
az role deny-assignment createandaz role deny-assignment deletecommands for managing user-assigned deny assignments, matching the existingaz role assignmentpattern.This implements the PUT/DELETE operations added in theMicrosoft.Authorization/denyAssignmentsAPI (2024-07-01-preview), as specified in TypeSpec PR #41617.### Two Assignment ModesThecreatecommand supports two modes for targeting principals:Everyone mode (default): Denies all principals at the scope. At least one excluded principal is required via--exclude-principal-ids:az role deny-assignment create --name "DenyAll" --scope /subscriptions/{sub} \ --actions "Microsoft.Compute/virtualMachines/delete" \ --exclude-principal-ids {your-object-id}Per-principal mode: Denies a specific User or ServicePrincipal via--principal-idand--principal-type:az role deny-assignment create --name "DenyUser" --scope /subscriptions/{sub} \ --actions "Microsoft.Compute/virtualMachines/delete" \ --principal-id {user-object-id} --principal-type User### Service ConstraintsUser-assigned deny assignments have specific restrictions enforced by the service:- Group principals are not permitted — only User or ServicePrincipal- No DataActions — only Actions/NotActions are supported- No Read actions — actions like*/readare not permitted- No DoNotApplyToChildScopes — this property is not supported- Single principal per UADA — one principal per deny assignment (enforced by backend)### Commands-az role deny-assignment list— List deny assignments (existing, enhanced)-az role deny-assignment show— Show a deny assignment (existing, enhanced)-az role deny-assignment create— Create a user-assigned deny assignment-az role deny-assignment delete— Delete a user-assigned deny assignment### Files Changed-commands.py— Command registration forrole deny-assignmentgroup-custom.py— Business logic with dual-mode principal handling and validation-_params.py— Parameter definitions including--principal-idand--principal-type-_help.py— Help text with examples for both Everyone and per-principal modes-linter_exclusions.yml— Exclusions for long parameter names-tests/latest/test_deny_assignment.py— Unit tests (list, show, CRUD, per-principal, Group rejection, param validation)### Dependency> Note: Thecreateanddeleteoperations depend on the Python SDK PR azure-sdk-for-python#46223 being merged first. This PR pinsazure-mgmt-authorizationto 5.0.0b2 (released 7 May 2026 on PyPI), which includes thecreate_or_updateanddeletemethods onDenyAssignmentsOperations.### TestingTests are included intest_deny_assignment.py. Full end-to-end testing requires:1. A subscription with theMicrosoft.Authorization/SubscriptionAllowedToOperateUserAssignedDenyAssignmentfeature flag registered2. The updated Python SDK with create/delete support### Related- TypeSpec PR: azure-rest-api-specs#41617 (merged)- Python SDK auto-gen PR: azure-sdk-for-python#46223 (awaiting review)- Go SDK auto-gen PR: azure-sdk-for-go#26544 (awaiting review)- Java SDK auto-gen PR: azure-sdk-for-java#48751 (awaiting review)- JS SDK auto-gen PR: azure-sdk-for-js#38079 (awaiting review)- PowerShell PR: azure-powershell#29340 (merged ✅)