Azure / Azure/azure-powershell
Remove-AzRoleAssignment : Multiple role definitions found with name ''
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
## Description
If a scope has multiple role assignments with an empty RoleDefinitionName, then Remove-AzRoleAssignment will fail with the following error:
PS C:\Users\kwill> $DeprecatedAccounts[0] | Remove-AzRoleAssignment
Remove-AzRoleAssignment : Multiple role definitions found with name ''. Specify role definition using it's Id instead.
At line:1 char:26
$DeprecatedAccounts[0] | Remove-AzRoleAssignment
~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : CloseError: (:) [Remove-AzRoleAssignment], InvalidOperationException
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.RemoveAzureRoleAssignmentCommand
To fix, RemoveAzureRoleAssignmentCommand.cs should include the roleDefinitionId in this section of code:
if (this.IsParameterBound(c => c.InputObject))
{
Scope = InputObject.Scope;
ObjectId = InputObject.ObjectId;
RoleDefinitionName = InputObject.RoleDefinitionName;
}
Contributor guide
Research direction
Start in RemoveAzureRoleAssignmentCommand.cs at the InputObject parameter-bound block and reproduce the failure with multiple role assignments whose RoleDefinitionName is empty. Trace how the input object's role definition identifier is handled there, then verify that piping the assignment to Remove-AzRoleAssignment succeeds without the ambiguous-name error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- authorization, cli, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100