-
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
[Role] Add az role definition show
command
#30593
Conversation
️✔️AzureCLI-FullTest
|
Hi @jiasli, |
|
rule | cmd_name | rule_message | suggest_message |
---|---|---|---|
role definition show | cmd role definition show added |
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
az role definition show
command az role definition show
command
c34504d
to
2fd55cd
Compare
@@ -370,6 +370,14 @@ class PrincipalType(str, Enum): | |||
|
|||
with self.argument_context('role definition') as c: | |||
c.argument('role_definition_id', options_list=['--name', '-n'], help='the role definition name') | |||
c.argument('role_id', options_list=['--id'], |
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.
The --ids
argument provided by Azure CLI core relies on azure.mgmt.core.tools.parse_resource_id
parts = parse_resource_id(val) |
which parses the resource ID into parts:
- subscription: Subscription id
- resource_group: Name of resource group
- namespace: Namespace for the resource provider (i.e. Microsoft.Compute)
- type: Type of the root resource (i.e. virtualMachines)
- name: Name of the root resource
- child_namespace_{level}: Namespace for the child resource of that level
- child_type_{level}: Type of the child resource of that level
- child_name_{level}: Name of the child resource of that level
- last_child_num: Level of the last child
- resource_parent: Computed parent in the following pattern: providers/{namespace}\
/{parent}/{type}/{name}
- resource_namespace: Same as namespace. Note that this may be different than the \
target resource's namespace.
- resource_type: Type of the target resource (not the parent)
- resource_name: Name of the target resource (not the parent)
However, it can't parse scope
, so we have to define our own --id
.
7d172d3
to
149c614
Compare
149c614
to
1758442
Compare
if not role_id and not (name and scope): | ||
raise CLIError('Usage error: Provide both --scope and --name') |
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.
--scope
should be a required argument to align with az role assignment create
and az ad sp create-for-rbac
.
Also see
Related command
az role definition show
Description
For
az role definition list
, #30587 started to useroleName
filter when--name
is a non-GUID string, but if the provided--name
is a GUID, this command still uses a client-side filter which is inefficient.name
cannot be used as afilter
and the API fails with:We can internally switch to Role Definitions - Get API when
--name
is a GUID and convert the result to a list, but this introduces complexity withinaz role definition list
commands, as it will have 2 code paths and need to handle 404 error returned by the Role Definitions - Get API.Having a dedicated
az role definition show
command is more consistent with other Azure CLI commands and the underlying REST API.Testing Guide