Implementing An Azure Custom Role Using Azure PowerShell

Azure Custom

Awesome! The custom role that has been registered in Azure and we can go ahead and make use of the role.

Deleting a Custom Role

In case if, you want to go ahead and delete that role, first delete the role assignment then after deleting the custom role. Otherwise, you will get an error as shown below

Remove-AzRoleDefinition: There are existing role assignments referencing role c5104a7d-4fcd-4eff-a2a3-8e883619417b. The role assignments must be deleted before the role can be deleted.

To remove role assignment, we can run the below command first. This command similar to a new role assignment. The following example removes My Custom Role assignment from the user on the cloud-shell-storage-westeurope resource group.

  1. Remove-AzRoleAssignment -ResourceGroupName cloud-shell-storage-westeurope -SignInName -RoleDefinitionName “My Custom Role”

To delete a custom role, use the Remove-AzRoleDefinition command.

  1. Get-AzRoleDefinition “My Custom Role” | Remove-AzRoleDefinition

You can easily achieve the same functionality through the Azure portal as well. For that, we need to delete the role assignment first then from the roles tab, select custom role, and then click on remove.


In this article, we have seen how we can create a custom role from Azure PowerShell and how newly created roles assigned to a user, and finally, we deleted that custom role. Hope you gained some insights into this topic and found this information useful!

Leave a Reply

Your email address will not be published. Required fields are marked *