-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Use roleName
filter to limit the results returned by az role definition list --name
#30579
Comments
Thank you for opening this issue, we will look into it. |
I guess downloading it once for all the role types might be more efficient if you take into account caching. Was just a curiosity i spotted when doing some testing. |
@kewalaka, you have sharp eyes! The role definition filtering is indeed performed on the client side: azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py Lines 140 to 150 in e8aa309
This is because, according to L145,
And the result is the same:
But I think you made a very good point. We may consider adding |
Most Azure CLI commands by far have no caching mechanism, as it is impossible to know when the data returned by the ARM service expires. Take https://learn.microsoft.com/en-us/rest/api/authorization/role-definitions/list?view=rest-authorization-2022-04-01&tabs=HTTP as an example, if a new role is created, CLI will not know that. Quering ARM service again will defeat the purpose of caching. |
Good point! I was thinking in the context of built in roles but of course that is too limiting. |
I did a quick test in #30587 and the number of returned role definitions reduced from 727 to 1, making However,
Azure CLI has been using
I'll internally discuss with RBAC team on this. |
az role definition --name
az role definition list --name
az role definition list --name
roleName
filter to limit the results returned by az role definition list --name
Related command
Any role definition list operation that filters by name, e.g.:
az role definition list --name "Contributor"
Is your feature request related to a problem? Please describe.
The call to the resource manager API fetches all the IDs:
Whilst the works, it seems unnecessarily costly given a specific name has been supplied.
Describe the solution you'd like
Consider specifying the role name if supplied, using the target query parameter:
Describe alternatives you've considered
n/a
Additional context
https://learn.microsoft.com/en-us/rest/api/authorization/role-definitions/list?view=rest-authorization-2022-04-01&tabs=HTTP#uri-parameters
The text was updated successfully, but these errors were encountered: