A company has a resource group named 'RG-Prod' that contains critical virtual machines (VMs), virtual networks, and a SQL database. The infrastructure team needs to grant a group of developers the ability to start, stop, and restart only the VMs in RG-Prod. The developers must not be able to create new VMs, delete existing VMs, modify the virtual networks, or access the database. The company wants to follow the principle of least privilege. Which Azure role-based access control (RBAC) approach should the company use?
A custom RBAC role allows you to define a precise set of allowed actions. By including only the start, deallocate, and restart actions, you grant exactly the permissions needed. The role does not include write or delete actions, so developers cannot create or delete VMs. Since VNet and database actions are not included, those resources are also protected. This meets the least privilege requirement.
Why this answer
The principle of least privilege requires granting only the exact permissions needed. The built-in Virtual Machine Contributor role includes permissions beyond start/stop/restart (e.g., it allows creating and deleting VMs), which violates the requirement. A custom RBAC role scoped to RG-Prod with only the specific actions (Microsoft.Compute/virtualMachines/start/action, Microsoft.Compute/virtualMachines/deallocate/action, and Microsoft.Compute/virtualMachines/restart/action) meets the need precisely.
Exam trap
The trap here is that candidates often assume built-in roles like Virtual Machine Contributor are sufficiently restrictive, but they actually include broader permissions (e.g., create, delete, modify) that violate the principle of least privilege when only start/stop/restart is needed.
Why the other options are wrong
The Virtual Machine Contributor role allows creating and deleting VMs, which violates the requirement that developers must not create or delete VMs.
Assigning the Contributor role grants full management access to all resources in the resource group, including creating and deleting VMs, modifying virtual networks, and accessing the SQL database, which violates the principle of least privilege and exceeds the required permissions.
The Reader role only allows read access, not the ability to start, stop, or restart VMs. Azure Policy cannot perform actions like starting/stopping VMs on behalf of users; it only enforces compliance rules.
When would these options actually be correct?
If the requirement were to grant full management of VMs (including creation and deletion) but not access to other resources like virtual networks or databases, the Virtual Machine Contributor role would be appropriate.
A company needs to grant a group of users Contributor-level access to a resource group but must prevent specific actions (e.g., VM creation or VNet modification) that are not allowed by the built-in role. In that case, assigning the Contributor role combined with an Azure Policy to deny those specific actions would be the correct approach.
A scenario where developers need read-only access to resources and an automated schedule (e.g., via Azure Automation) handles VM start/stop operations based on tags or schedules, with no manual intervention required.
Why candidates pick the wrong answer
Candidates may assume that a built-in role named 'Virtual Machine Contributor' is limited to start/stop/restart actions, but it actually includes broader permissions like VM creation and deletion.
Candidates may think that combining a broad role with a restrictive policy is an efficient way to achieve least privilege without creating a custom role, underestimating the complexity and potential for misconfiguration in policy definitions.
Candidates may think Azure Policy can automate actions, confusing its compliance enforcement with actual execution capabilities, or they may believe Reader plus policy can achieve the desired result without understanding RBAC limitations.