Skip to content

Commit 639051b

Browse files
committed
role-scope
1 parent f92f723 commit 639051b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/azure-cli/azure/cli/command_modules/role/_help.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,10 @@
773773
type: command
774774
short-summary: Delete role assignments.
775775
examples:
776-
- name: Delete role assignments. (autogenerated)
777-
text: |
778-
az role assignment delete --assignee 00000000-0000-0000-0000-000000000000 --role "Storage Account Key Operator Service Role"
779-
crafted: true
776+
- name: Delete role assignments by resource ID.
777+
text: az role assignment delete --ids /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000
778+
- name: Delete role assignments that satisfies the query conditions.
779+
text: az role assignment delete --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup --assignee 00000000-0000-0000-0000-000000000000 --role Reader
780780
"""
781781

782782
helps['role assignment list'] = """
@@ -791,6 +791,11 @@
791791
After August 31, 2024, all classic administrators risk losing access to the subscription.
792792
Delete classic administrators who no longer need access or assign an Azure RBAC role for fine-grained access
793793
control. Learn more: https://go.microsoft.com/fwlink/?linkid=2238474
794+
examples:
795+
- name: List role assignments for a subscription
796+
text: az role assignment list --scope /subscriptions/00000000-0000-0000-0000-000000000000
797+
- name: List role assignments for a resource group
798+
text: az role assignment list --scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup
794799
"""
795800

796801
helps['role assignment list-changelogs'] = """

src/azure-cli/azure/cli/command_modules/role/custom.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@
5656
"Delete classic administrators who no longer need access or assign an Azure RBAC role for fine-grained access "
5757
"control. Learn more: https://go.microsoft.com/fwlink/?linkid=2238474")
5858

59+
ROLE_ASSIGNMENT_LIST_SCOPE_WARNING = (
60+
"--scope argument will become required for listing role assignments "
61+
"in the breaking change release of the spring of 2025. "
62+
"Please explicitly specify --scope.")
63+
64+
ROLE_ASSIGNMENT_DELETE_SCOPE_WARNING = (
65+
"When --ids is not provided, --scope argument will become required for deleting role assignments "
66+
"in the breaking change release of the spring of 2025. "
67+
"Please explicitly specify --scope.")
68+
5969
logger = get_logger(__name__)
6070

6171
# pylint: disable=too-many-lines, protected-access
@@ -219,6 +229,9 @@ def list_role_assignments(cmd, assignee=None, role=None, resource_group_name=Non
219229
:param include_groups: include extra assignments to the groups of which the user is a
220230
member(transitively).
221231
'''
232+
if not scope:
233+
logger.warning(ROLE_ASSIGNMENT_LIST_SCOPE_WARNING)
234+
222235
if include_classic_administrators:
223236
logger.warning(CLASSIC_ADMINISTRATOR_WARNING)
224237

@@ -502,6 +515,9 @@ def _get_displayable_name(graph_object):
502515

503516
def delete_role_assignments(cmd, ids=None, assignee=None, role=None, resource_group_name=None,
504517
scope=None, include_inherited=False, yes=None):
518+
if not ids and not scope:
519+
logger.warning(ROLE_ASSIGNMENT_DELETE_SCOPE_WARNING)
520+
505521
factory = _auth_client_factory(cmd.cli_ctx, scope)
506522
assignments_client = factory.role_assignments
507523
definitions_client = factory.role_definitions

0 commit comments

Comments
 (0)