|
| 1 | +--- |
| 2 | +title: Grant RBAC access to Azure reservations using PowerShell |
| 3 | +description: Learn how to delegate access management for Azure reservations using PowerShell. |
| 4 | +author: dekadays |
| 5 | +ms.reviewer: sornaks |
| 6 | +ms.service: cost-management-billing |
| 7 | +ms.subservice: reservations |
| 8 | +ms.custom: devx-track-azurepowershell |
| 9 | +ms.topic: how-to |
| 10 | +ms.date: 08/21/2025 |
| 11 | +ms.author: liuyizhu |
| 12 | + |
| 13 | +#CustomerIntent: As a billing administrator, I want to learn about granting RBAC access to Azure Reservations using PowerShell so that I can assign permissions effectively. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +# Grant RBAC access to Azure reservations using PowerShell |
| 18 | + |
| 19 | +This article shows you how to grant Role-Based Access Control (RBAC) access to Azure reservations using PowerShell. To view and manage RBAC access in Azure Portal, see [Permissions to view and manage Azure reservations](view-reservations.md). |
| 20 | + |
| 21 | +[!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)] |
| 22 | + |
| 23 | +## Grant access with PowerShell |
| 24 | + |
| 25 | +Users that have owner access for reservations orders, users with elevated access, and [User Access Administrators](../../role-based-access-control/built-in-roles.md#user-access-administrator) can delegate access management for all reservation orders they have access to. |
| 26 | + |
| 27 | +Access granted using PowerShell isn't shown in the Azure portal. Instead, you use the `get-AzRoleAssignment` command in the following section to view assigned roles. |
| 28 | + |
| 29 | +## Assign the owner role for all reservations |
| 30 | + |
| 31 | +Use the following Azure PowerShell script to give a user Azure RBAC access to all reservations orders in their Microsoft Entra tenant (directory). |
| 32 | + |
| 33 | +```azurepowershell |
| 34 | +
|
| 35 | +Import-Module Az.Accounts |
| 36 | +Import-Module Az.Resources |
| 37 | + |
| 38 | +Connect-AzAccount -Tenant <TenantId> |
| 39 | + |
| 40 | +$response = Invoke-AzRestMethod -Path /providers/Microsoft.Capacity/reservations?api-version=2020-06-01 -Method GET |
| 41 | + |
| 42 | +$responseJSON = $response.Content | ConvertFrom-JSON |
| 43 | + |
| 44 | +$reservationObjects = $responseJSON.value |
| 45 | + |
| 46 | +foreach ($reservation in $reservationObjects) |
| 47 | +{ |
| 48 | + $reservationOrderId = $reservation.id.substring(0, 84) |
| 49 | + Write-Host "Assigning Owner role assignment to "$reservationOrderId |
| 50 | + New-AzRoleAssignment -Scope $reservationOrderId -ObjectId <ObjectId> -RoleDefinitionName Owner |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +When you use the PowerShell script to assign the ownership role and it runs successfully, a success message isn’t returned. |
| 55 | + |
| 56 | +### Parameters |
| 57 | + |
| 58 | +**-ObjectId** Microsoft Entra ObjectId of the user, group, or service principal. |
| 59 | +- Type: String |
| 60 | +- Aliases: Id, PrincipalId |
| 61 | +- Position: Named |
| 62 | +- Default value: None |
| 63 | +- Accept pipeline input: True |
| 64 | +- Accept wildcard characters: False |
| 65 | + |
| 66 | +**-TenantId** Tenant unique identifier. |
| 67 | +- Type: String |
| 68 | +- Position: 5 |
| 69 | +- Default value: None |
| 70 | +- Accept pipeline input: False |
| 71 | +- Accept wildcard characters: False |
| 72 | + |
| 73 | +## Tenant-level access |
| 74 | + |
| 75 | +[User Access Administrator](../../role-based-access-control/built-in-roles.md#user-access-administrator) rights are required before you can grant users or groups the Reservations Administrator, Reservations Contributor, and Reservations Reader roles at the tenant level. In order to get User Access Administrator rights at the tenant level, follow [Elevate access](../../role-based-access-control/elevate-access-global-admin.md) steps. |
| 76 | + |
| 77 | +### Add a Reservations Administrator role, Reservations Contributor role, or Reservations Reader role at the tenant level |
| 78 | +Only Global Administrators can assign these roles from the [Azure portal](https://portal.azure.com). |
| 79 | + |
| 80 | +1. Sign in to the Azure portal and navigate to **Reservations**. |
| 81 | +1. Select a reservation that you have access to. |
| 82 | +1. At the top of the page, select **Role Assignment**. |
| 83 | +1. Select the **Roles** tab. |
| 84 | +1. To make modifications, add a user as a Reservations Administrator, Reservations Contributor, or Reservations Reader using Access control. |
| 85 | + |
| 86 | +### Add a Reservation Administrator role at the tenant level using Azure PowerShell script |
| 87 | + |
| 88 | +Use the following Azure PowerShell script to add a Reservation Administrator role at the tenant level with PowerShell. |
| 89 | + |
| 90 | +```azurepowershell |
| 91 | +Import-Module Az.Accounts |
| 92 | +Import-Module Az.Resources |
| 93 | +Connect-AzAccount -Tenant <TenantId> |
| 94 | +New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -PrincipalId <ObjectId> -RoleDefinitionName "Reservations Administrator" |
| 95 | +``` |
| 96 | + |
| 97 | +#### Parameters |
| 98 | + |
| 99 | +**-ObjectId** Microsoft Entra ObjectId of the user, group, or service principal. |
| 100 | +- Type: String |
| 101 | +- Aliases: Id, PrincipalId |
| 102 | +- Position: Named |
| 103 | +- Default value: None |
| 104 | +- Accept pipeline input: True |
| 105 | +- Accept wildcard characters: False |
| 106 | + |
| 107 | +**-TenantId** Tenant unique identifier. |
| 108 | +- Type: String |
| 109 | +- Position: 5 |
| 110 | +- Default value: None |
| 111 | +- Accept pipeline input: False |
| 112 | +- Accept wildcard characters: False |
| 113 | + |
| 114 | +### Add a Reservation Contributor role at the tenant level using Azure PowerShell script |
| 115 | + |
| 116 | +Use the following Azure PowerShell script to add a Reservation Contributor role at the tenant level with PowerShell. |
| 117 | + |
| 118 | +```azurepowershell |
| 119 | +Import-Module Az.Accounts |
| 120 | +Import-Module Az.Resources |
| 121 | +Connect-AzAccount -Tenant <TenantId> |
| 122 | +New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -PrincipalId <ObjectId> -RoleDefinitionName "Reservations Contributor" |
| 123 | +``` |
| 124 | + |
| 125 | +#### Parameters |
| 126 | + |
| 127 | +**-ObjectId** Microsoft Entra ObjectId of the user, group, or service principal. |
| 128 | +- Type: String |
| 129 | +- Aliases: Id, PrincipalId |
| 130 | +- Position: Named |
| 131 | +- Default value: None |
| 132 | +- Accept pipeline input: True |
| 133 | +- Accept wildcard characters: False |
| 134 | + |
| 135 | +**-TenantId** Tenant unique identifier. |
| 136 | +- Type: String |
| 137 | +- Position: 5 |
| 138 | +- Default value: None |
| 139 | +- Accept pipeline input: False |
| 140 | +- Accept wildcard characters: False |
| 141 | + |
| 142 | +### Assign a Reservation Reader role at the tenant level using Azure PowerShell script |
| 143 | + |
| 144 | +Use the following Azure PowerShell script to assign the Reservation Reader role at the tenant level with PowerShell. |
| 145 | + |
| 146 | +```azurepowershell |
| 147 | +
|
| 148 | +Import-Module Az.Accounts |
| 149 | +Import-Module Az.Resources |
| 150 | +
|
| 151 | +Connect-AzAccount -Tenant <TenantId> |
| 152 | +
|
| 153 | +New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -PrincipalId <ObjectId> -RoleDefinitionName "Reservations Reader" |
| 154 | +``` |
| 155 | + |
| 156 | +#### Parameters |
| 157 | + |
| 158 | +**-ObjectId** Microsoft Entra ObjectId of the user, group, or service principal. |
| 159 | +- Type: String |
| 160 | +- Aliases: Id, PrincipalId |
| 161 | +- Position: Named |
| 162 | +- Default value: None |
| 163 | +- Accept pipeline input: True |
| 164 | +- Accept wildcard characters: False |
| 165 | + |
| 166 | +**-TenantId** Tenant unique identifier. |
| 167 | +- Type: String |
| 168 | +- Position: 5 |
| 169 | +- Default value: None |
| 170 | +- Accept pipeline input: False |
| 171 | +- Accept wildcard characters: False |
| 172 | + |
| 173 | + |
| 174 | +## Next steps |
| 175 | + |
| 176 | +- [Permissions to view and manage Azure reservations](view-reservations.md) |
| 177 | +- [Manage Azure Reservations](manage-reserved-vm-instance.md) |
| 178 | +- [Azure built-in roles for reservations](../../role-based-access-control/built-in-roles.md#reservations-administrator) |
0 commit comments