Task: Implement a Custom Role

Video: Custom Roles

Estimated time: 30 minutes

Goal

The goal of this task is to create a custom RBAC role and assign it to a test user on a resource group. The custom role will be a variation of the Contributor role that does not allow the deletion of any resources.

Pre-requisites

  1. Non-production Azure subscription
  2. An Azure AD cloud user named tasks for testing access

Requirements

  1. Requirement 1: Define a custom role
  2. Requirement 2: Assign the custom role
  3. Requirement 3: Test the custom role

Pre-requisite setup

You can create a new Azure AD user from the bash cloud shell by running the following command (substitute your values for the domain name and password):

az ad user create --display-name tasks --password <your password> --user-principal-name tasks@<your domain> --force-change-password-next-login false

Example

az ad user create --display-name tasks --password B@dPa55word! --user-principal-name tasks@inedemos.onmicrosoft.com --force-change-password-next-login false

Requirement 1: Define a custom role

To complete this requirement, you must create a custom role named Contributor-Limited with the same permissions as the Contributor role, except without the ability to delete any resources. Take the following steps in a bash cloud shell to complete the requirement:

code ./customRole.json

Requirement 2: Assign the custom role

To complete this requirement, you must provision a new resource group named task-role-rg. Assign the Contributor-Limited role to the tasks user on the task-role-rg resource group.

Requirement 3: Test the custom role

To complete this task you must log in to the Azure portal as the tasks user and verify the rights granted the user on the task-role-rg resource group. To complete this requirement:

Cleanup

When you have completed this task, delete the task-role-rg resource group and the Contributor-Limited role.