-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Role] az role assignment list: Add --fill-role-definition-name
#31152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
️✔️AzureCLI-FullTest
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| role assignment list | cmd role assignment list added parameter fill_role_definition_name |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
9d6e08e to
66cd34d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This recording file previously contains 8 requests with /providers/Microsoft.Authorization/roleDefinitions?api-version=2022-05-01-preview. Now it contains only 4.
66cd34d to
280f5c6
Compare
|
Please fix the PR description, the command name is |
Nice catch. Fixed. |
az role assignment list: Add --fill-role-definition-name to allow omitting principalName propertyaz role assignment list: Add --fill-role-definition-name
| self.cmd('role assignment list --scope {rg_id} --fill-principal-name false ' | ||
| '--fill-role-definition-name false', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--asignee requires Graph query and --assignee-object-id is not supported yet (#30469), so we can only use --scope+atScope() query for now:
azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Lines 582 to 586 in d4147a7
| if scope: | |
| f = 'atScope()' # atScope() excludes role assignments at subscopes | |
| if assignee_object_id and include_groups: | |
| f = f + " and assignedTo('{}')".format(assignee_object_id) | |
| assignments = list(assignments_client.list_for_scope(scope=scope, filter=f)) |
This records the subscription assignments, making the recording file big.
Once --assignee-object-id is not supported (#30469), we can switch to
azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Lines 587 to 592 in d4147a7
| elif assignee_object_id: | |
| if include_groups: | |
| f = "assignedTo('{}')".format(assignee_object_id) | |
| else: | |
| f = "principalId eq '{}'".format(assignee_object_id) | |
| assignments = list(assignments_client.list_for_subscription(filter=f)) |
Related command
az role assignment listDescription
With the ever-increasing number of built-in roles, the list returned by Role Definitions - List API is getting bigger and bigger (#30579), making
az role assignment listcommand slower.In our test subscription,
role_defsatazure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Lines 273 to 274 in 919923c
contains 653 items with the size of 588563 bytes, bloating recording files to megabytes big, exceeding the limit of Git diff.
This PR adds
--fill-role-definition-nameto allow omittingroleDefinitionNameproperty, similar to #30693.#30587 uses
roleNamefilter to accelerateaz role definition list, but foraz role assignment list, this would require making a REST call for each role definition. Giving the user the choice whether to fillroleDefinitionNameproperty is still mandatory.Testing Guide
Without
--fill-role-definition-name false:With
--fill-role-definition-name false:History Notes
[Role]
az role assignment list: Add--fill-role-definition-nameargument. Use--fill-role-definition-name falseto omitroleDefinitionNameproperty and bypass the role definitions query