|
1 | 1 | ---
|
2 | 2 | title: Add owners and users
|
3 |
| -description: Add owners and users in Azure DevTest Labs using either the Azure portal or PowerShell |
| 3 | +description: Learn about the Azure DevTest Labs Owner, Contributor, and DevTest Labs User roles, and how to add members to lab roles by using the Azure portal or Azure PowerShell. |
4 | 4 | ms.topic: how-to
|
5 |
| -ms.date: 06/26/2020 |
| 5 | +ms.date: 01/21/2022 |
6 | 6 | ms.custom: devx-track-azurepowershell
|
7 | 7 | ---
|
8 | 8 |
|
9 |
| -# Add owners and users in Azure DevTest Labs |
10 |
| - |
11 |
| -Access in Azure DevTest Labs is controlled by [Azure role-based access control (Azure RBAC)](../role-based-access-control/overview.md). Using Azure RBAC, you can segregate duties within your team into *roles* where you grant only the amount of access necessary to users to perform their jobs. Three of these Azure roles are *Owner*, *DevTest Labs User*, and *Contributor*. In this article, you learn what actions can be performed in each of the three main Azure roles. From there, you learn how to add users to a lab - both via the portal and via a PowerShell script, and how to add users at the subscription level. |
12 |
| - |
13 |
| -## Actions that can be performed in each role |
14 |
| -There are three main roles that you can assign a user: |
15 |
| - |
16 |
| -* Owner |
17 |
| -* DevTest Labs User |
18 |
| -* Contributor |
19 |
| - |
20 |
| -The following table illustrates the actions that can be performed by users in each of these roles: |
21 |
| - |
22 |
| -| **Actions users in this role can perform** | **DevTest Labs User** | **Owner** | **Contributor** | |
23 |
| -| --- | --- | --- | --- | |
24 |
| -| **Lab tasks** | | | | |
25 |
| -| Add users to a lab |No |Yes |No | |
26 |
| -| Update cost settings |No |Yes |Yes | |
27 |
| -| **VM base tasks** | | | | |
28 |
| -| Add and remove custom images |No |Yes |Yes | |
29 |
| -| Add, update, and delete formulas |Yes |Yes |Yes | |
30 |
| -| Enable Marketplace images |No |Yes |Yes | |
31 |
| -| **VM tasks** | | | | |
32 |
| -| Create VMs |Yes |Yes |Yes | |
33 |
| -| Start, stop, and delete VMs |Only VMs created by the user |Yes |Yes | |
34 |
| -| Update VM policies |No |Yes |Yes | |
35 |
| -| Add/remove data disks to/from VMs |Only VMs created by the user |Yes |Yes | |
36 |
| -| **Artifact tasks** | | | | |
37 |
| -| Add and remove artifact repositories |No |Yes |Yes | |
38 |
| -| Apply artifacts |Yes |Yes |Yes | |
| 9 | +# Azure DevTest Labs owners, contributors, and users |
39 | 10 |
|
40 |
| -> [!NOTE] |
41 |
| -> When a user creates a VM, that user is automatically assigned to the **Owner** role of the created VM. |
42 |
| -> |
43 |
| -> |
| 11 | +This article describes the three built-in Azure DevTest Labs roles: *Owner*, *Contributor*, and *DevTest Labs User*, and how to add users with those roles to labs. DevTest Labs uses Azure [role-based access control](../role-based-access-control/overview.md) (Azure RBAC) to define roles that have only the necessary access to do certain lab tasks. This article describes the tasks each role can do, and how to add users to lab roles by using the Azure portal or an Azure PowerShell script. |
44 | 12 |
|
45 |
| -## Add an owner or user at the lab level |
46 |
| -Owners and users can be added at the lab level via the Azure portal. |
47 |
| -A user can be an external user with a valid [Microsoft account (MSA)](./devtest-lab-faq.yml). |
48 |
| -The following steps guide you through the process of adding an owner or user to a lab in Azure DevTest Labs: |
| 13 | +## Actions each role can take |
49 | 14 |
|
50 |
| -1. Sign in to the [Azure portal](https://portal.azure.com) as [User Access Administrator](../role-based-access-control/built-in-roles.md#user-access-administrator) or [Owner](../role-based-access-control/built-in-roles.md#owner). |
| 15 | +Lab Owner, Contributor, and DevTest Labs User roles can take the following actions in DevTest Labs: |
51 | 16 |
|
52 |
| -1. Open the desired resource group and select **DevTest Labs**. |
| 17 | +### Owner |
53 | 18 |
|
54 |
| -1. In the navigation menu, select **Access control (IAM)**. |
| 19 | +The lab Owner role can take all of the following actions: |
55 | 20 |
|
56 |
| -1. Select **Add** > **Add role assignment**. |
| 21 | +Lab tasks: |
| 22 | +- Add users to the lab |
| 23 | +- Update cost settings |
57 | 24 |
|
58 |
| -  |
| 25 | +Virtual machine (VM) base tasks: |
| 26 | +- Add and remove custom images |
| 27 | +- Add, update, and delete formulas |
| 28 | +- Enable Marketplace images |
59 | 29 |
|
60 |
| -1. On the **Role** tab, select the **OWNER** or **USER** role. |
| 30 | +VM tasks: |
| 31 | +- Create VMs |
| 32 | +- Start, stop, or delete VMs |
| 33 | +- Update VM policies |
| 34 | +- Add or remove VM data disks |
61 | 35 |
|
62 |
| -  |
| 36 | +Artifact tasks: |
| 37 | +- Add and remove artifact repositories |
| 38 | +- Apply artifacts to VMs |
63 | 39 |
|
64 |
| -1. On the **Members** tab, select the user you want to give the desired role to. |
| 40 | +### Contributor |
65 | 41 |
|
66 |
| -1. On the **Review + assign** tab, select **Review + assign** to assign the role. |
| 42 | +The lab Contributor role can take all the same actions as lab Owner, except it can't add users to labs. |
67 | 43 |
|
| 44 | +### DevTest Labs User |
68 | 45 |
|
69 |
| -## Add an external user to a lab using PowerShell |
| 46 | +The DevTest Labs User role can take the following actions in DevTest Labs: |
70 | 47 |
|
71 |
| -[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)] |
| 48 | +- Add, update, and delete VM base formulas. |
| 49 | +- Create VMs. |
| 50 | +- Start, stop, or delete VMs the user creates. |
| 51 | +- Add or remove data disks from VMs the user creates. |
| 52 | +- Apply artifacts to VMs. |
| 53 | + |
| 54 | +> [!NOTE] |
| 55 | +> Lab users automatically have the **Owner** role on VMs they create. |
| 56 | +
|
| 57 | +## Add Owners, Contributors, or DevTest Labs Users |
72 | 58 |
|
73 |
| -In addition to adding users in the Azure portal, you can add an external user to your lab using a PowerShell script. |
74 |
| -In the following example, modify the parameter values under the **Values to change** comment. |
75 |
| -You can retrieve the `subscriptionId`, `labResourceGroup`, and `labName` values from the lab blade in the Azure portal. |
| 59 | +A lab Owner can add members to lab roles by using the Azure portal or an Azure PowerShell script. The user to add can be an external user with a valid [Microsoft account (MSA)](./devtest-lab-faq.yml). |
| 60 | + |
| 61 | +Azure permissions propagate from parent scope to child scope. Owners of an Azure subscription that contains labs are automatically owners of the subscription's DevTest Labs service, the labs, and the VMs and other resources they contain. Subscription owners can add Owners, Contributors, and DevTest Labs Users to labs in the subscription. |
76 | 62 |
|
77 | 63 | > [!NOTE]
|
78 |
| -> The sample script assumes that the specified user has been added as a guest to the Active Directory, and will fail if that is not the case. To add a user not in the Active Directory to a lab, use the Azure portal to assign the user to a role as illustrated in the section, [Add an owner or user at the lab level](#add-an-owner-or-user-at-the-lab-level). |
79 |
| -> |
80 |
| -> |
| 64 | +> Added lab Owners' scope of administration is narrower than the subscription owner's scope. Added Owners don't have full access to some resources that the DevTest Labs service creates. |
81 | 65 |
|
82 |
| -```azurepowershell |
83 |
| -# Add an external user in DevTest Labs user role to a lab |
84 |
| -# Ensure that guest users can be added to the Azure Active directory: |
85 |
| -# https://azure.microsoft.com/documentation/articles/active-directory-create-users/#set-guest-user-access-policies |
| 66 | +### Prerequisites |
86 | 67 |
|
87 |
| -# Values to change |
88 |
| -$subscriptionId = "<Enter Azure subscription ID here>" |
89 |
| -$labResourceGroup = "<Enter lab's resource name here>" |
90 |
| -$labName = "<Enter lab name here>" |
91 |
| -$userDisplayName = "<Enter user's display name here>" |
| 68 | +- You must be an Owner of the lab, either directly or by inheritance as a subscription owner. |
| 69 | +- Sign in to the [Azure portal](https://portal.azure.com) as an [Owner](../role-based-access-control/built-in-roles.md#owner) or [User Access Administrator](../role-based-access-control/built-in-roles.md#user-access-administrator). |
92 | 70 |
|
93 |
| -# Log into your Azure account |
94 |
| -Connect-AzAccount |
| 71 | +### Add a member to a lab by using the Azure portal |
95 | 72 |
|
96 |
| -# Select the Azure subscription that contains the lab. |
97 |
| -# This step is optional if you have only one subscription. |
98 |
| -Select-AzSubscription -SubscriptionId $subscriptionId |
| 73 | +- To add a user at the subscription level, open the subscription page. |
| 74 | +- To add a user at the lab level, open the resource group that has the lab, and select the lab from the list of resources. |
99 | 75 |
|
100 |
| -# Retrieve the user object |
101 |
| -$adObject = Get-AzADUser -SearchString $userDisplayName |
| 76 | +1. In the left navigation for the subscription or lab, select **Access control (IAM)**. |
102 | 77 |
|
103 |
| -# Create the role assignment. |
104 |
| -$labId = ('subscriptions/' + $subscriptionId + '/resourceGroups/' + $labResourceGroup + '/providers/Microsoft.DevTestLab/labs/' + $labName) |
105 |
| -New-AzRoleAssignment -ObjectId $adObject.Id -RoleDefinitionName 'DevTest Labs User' -Scope $labId |
106 |
| -``` |
| 78 | +1. Select **Add** > **Add role assignment**. |
107 | 79 |
|
108 |
| -## Add an owner or user at the subscription level |
109 |
| -Azure permissions are propagated from parent scope to child scope in Azure. Therefore, owners of an Azure subscription that contains labs are automatically owners of those labs. They also own the VMs and other resources created by the lab's users, and the Azure DevTest Labs service. |
| 80 | +  |
110 | 81 |
|
111 |
| -You can add additional owners to a lab via the lab's blade in the [Azure portal](https://go.microsoft.com/fwlink/p/?LinkID=525040). |
112 |
| -However, the added owner's scope of administration is more narrow than the subscription owner's scope. |
113 |
| -For example, the added owners do not have full access to some of the resources that are created in the subscription by the DevTest Labs service. |
| 82 | +1. On the **Add Role Assignment** page, select the **Owner**, **Contributor**, or **User** role, and then select **Next**. |
114 | 83 |
|
115 |
| -To add an owner to an Azure subscription, follow these steps: |
| 84 | +  |
116 | 85 |
|
117 |
| -1. Sign in to the [Azure portal](https://portal.azure.com) as [User Access Administrator](../role-based-access-control/built-in-roles.md#user-access-administrator) or [Owner](../role-based-access-control/built-in-roles.md#owner). |
| 86 | +1. On the **Members** tab, select **Select members**. |
118 | 87 |
|
119 |
| -1. Open the desired Subscription group. |
| 88 | +1. On the **Select members** screen, select the member you want to add, and then select **Select**. |
120 | 89 |
|
121 |
| -1. In the navigation menu, select **Access control (IAM)**. |
| 90 | +1. Select **Review + assign**, and after reviewing the details, select **Review + assign** again. |
122 | 91 |
|
123 |
| -1. Select **Add** > **Add role assignment**. |
| 92 | +### Add a DevTest Labs User to a lab by using Azure PowerShell |
| 93 | + |
| 94 | +[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)] |
| 95 | + |
| 96 | +You can add a DevTest Labs User to a lab by using the following Azure PowerShell script. The script requires the user to be in the Azure Active Directory (Azure AD). For information about adding an external user to Azure AD as a guest, see [Add a new guest user](/active-directory/fundamentals/add-users-azure-active-directory#add-a-new-guest-user). If the user isn't in Azure AD, the script fails. Use the portal procedure instead. |
| 97 | + |
| 98 | +In the following script, update the parameter values under the `# Values to change` comment. You can get the `subscriptionId`, `labResourceGroup`, and `labName` values from the lab's main page in the Azure portal. |
| 99 | + |
| 100 | +```azurepowershell |
| 101 | +# Add an external user to a lab user role in DevTest Labs. |
| 102 | +# Make sure the guest user is added to Azure AD. |
124 | 103 |
|
125 |
| -  |
| 104 | +# Values to change |
| 105 | +$subscriptionId = "<Azure subscription ID>" |
| 106 | +$labResourceGroup = "<Lab's resource group name>" |
| 107 | +$labName = "<Lab name>" |
| 108 | +$userDisplayName = "<User's display name>" |
126 | 109 |
|
127 |
| -1. On the **Role** tab, select the **OWNER** role. |
| 110 | +# Log into your Azure account. |
| 111 | +Connect-AzAccount |
128 | 112 |
|
129 |
| -  |
| 113 | +# Select the Azure subscription that contains the lab. This step is optional if you have only one subscription. |
| 114 | +Select-AzSubscription -SubscriptionId $subscriptionId |
130 | 115 |
|
131 |
| -1. On the **Members** tab, select the user you want to give the owner role to. |
| 116 | +# Get the user object. |
| 117 | +$adObject = Get-AzADUser -SearchString $userDisplayName |
132 | 118 |
|
133 |
| -1. On the **Review + assign** tab, select **Review + assign** to assign the role. |
| 119 | +# Create the role assignment. |
| 120 | +$labId = ('subscriptions/' + $subscriptionId + '/resourceGroups/' + $labResourceGroup + '/providers/Microsoft.DevTestLab/labs/' + $labName) |
| 121 | +New-AzRoleAssignment -ObjectId $adObject.Id -RoleDefinitionName 'DevTest Labs User' -Scope $labId |
| 122 | +``` |
134 | 123 |
|
| 124 | +## Next steps |
135 | 125 |
|
136 |
| -[!INCLUDE [devtest-lab-try-it-out](../../includes/devtest-lab-try-it-out.md)] |
| 126 | +- [Customize permissions with custom roles](devtest-lab-grant-user-permissions-to-specific-lab-policies.md) |
| 127 | +- [Automate adding lab users](automate-add-lab-user.md) |
0 commit comments