|
1 | 1 | ---
|
2 |
| -title: Understand Device Update for IoT Hub authentication and authorization |
3 |
| -description: Understand how Device Update for IoT Hub uses Azure RBAC to provide authentication and authorization for users and service APIs. |
| 2 | +title: Azure RBAC and Azure Device Update for IoT Hub |
| 3 | +description: Understand how Azure Device Update for IoT Hub uses Azure role-based access control (Azure RBAC) to provide authentication and authorization for users and service APIs. |
4 | 4 | author: vimeht
|
5 | 5 | ms.author: vimeht
|
6 |
| -ms.date: 10/21/2022 |
| 6 | +ms.date: 01/13/2025 |
7 | 7 | ms.topic: concept-article
|
8 | 8 | ms.service: azure-iot-hub
|
9 | 9 | ms.subservice: device-update
|
10 | 10 | ---
|
11 | 11 |
|
12 |
| -# Azure role-based access control (RBAC) and Device Update |
| 12 | +# Azure Device Update for IoT Hub and Azure RBAC |
13 | 13 |
|
14 |
| -Device Update uses Azure RBAC to provide authentication and authorization for users and service APIs. In order for other users and applications to have access to Device Update, users or applications must be granted access to this resource. It is also necessary to [configure access for Azure Device Update service principal](./device-update-control-access.md#configuring-access-for-azure-device-update-service-principal-in-the-iot-hub) for successfully deploying updates and managing your devices. |
| 14 | +For users and applications to access Azure Device Update for IoT Hub, they must be granted access to the Device Update resource. You must also configure access for the Device Update service principal to access the IoT hub to deploy updates and manage devices. This article explains how Device Update uses Azure role-based access control (Azure RBAC) to provide authentication and authorization for users and service APIs. |
15 | 15 |
|
16 |
| -## Configure access control roles |
| 16 | +## Device Update access control roles |
17 | 17 |
|
18 |
| - These are the roles that are supported by Device Update: |
| 18 | +Device Update supports the following RBAC roles: |
19 | 19 |
|
20 | 20 | | Role Name | Description |
|
21 | 21 | | :--------- | :---- |
|
22 | 22 | | Device Update Administrator | Has access to all Device Update resources |
|
23 | 23 | | Device Update Reader| Can view all updates and deployments |
|
24 | 24 | | Device Update Content Administrator | Can view, import, and delete updates |
|
25 | 25 | | Device Update Content Reader | Can view updates |
|
26 |
| -| Device Update Deployments Administrator | Can manage deployment of updates to devices| |
| 26 | +| Device Update Deployments Administrator | Can manage deployments of updates to devices| |
27 | 27 | | Device Update Deployments Reader| Can view deployments of updates to devices |
|
28 | 28 |
|
29 |
| -A combination of roles can be used to provide the right level of access. For example, a developer can import and manage updates using the Device Update Content Administrator role, but needs a Device Update Deployments Reader role to view the progress of an update. Conversely, a solution operator with the Device Update Reader role can view all updates, but needs to use the Device Update Deployments Administrator role to deploy a specific update to devices. |
| 29 | +You can assign a combination of roles to provide the right level of access. For example, the Device Update Content Administrator role can import and manage updates, but you need the Device Update Deployments Reader role to view the progress of an update. Conversely, the Device Update Reader role can view all updates, but you need the Device Update Deployments Administrator role to deploy a specific update to devices. |
30 | 30 |
|
31 |
| -## Configuring access for Azure Device Update service principal in the IoT Hub |
| 31 | +## Device Update service principal access to IoT Hub |
32 | 32 |
|
33 |
| -Device Update for IoT Hub communicates with the IoT Hub for deployments and manage updates at scale. In order to enable Device Update to do this, users need to set IoT Hub Data Contributor access for Azure Device Update Service Principal in the IoT Hub permissions. |
| 33 | +Device Update communicates with the IoT hub for deployments and to manage updates at scale. To enable this communication, you need to use the IoT hub access permissions to grant IoT Hub Data Contributor access to the Device Update service principal. |
34 | 34 |
|
35 |
| -Deployment, device and update management and diagnostic actions will not be allowed if these permissions are not set. Operations that will be blocked will include: |
36 |
| -* Create Deployment |
37 |
| -* Cancel Deployment |
38 |
| -* Retry Deployment |
39 |
| -* Get Device |
| 35 | +You must set these permissions to allow the following deployment, device and update management, and diagnostic actions: |
40 | 36 |
|
41 |
| -The permission can be set from IoT Hub Access Control (IAM). Refer to [Configure Access for Azure Device update service principal in linked IoT hub](configure-access-control-device-update.md#configure-access-for-azure-device-update-service-principal-in-linked-iot-hub) |
| 37 | +- Create deployment |
| 38 | +- Cancel deployment |
| 39 | +- Retry deployment |
| 40 | +- Get device |
42 | 41 |
|
43 |
| -## Authenticate to Device Update REST APIs |
| 42 | +You can set this permission from the IoT hub access control (IAM) page. For more information, see [Configure IoT hub access for the Device Update service principal](configure-access-control-device-update.md#configure-access-for-azure-device-update-service-principal-in-linked-iot-hub). |
| 43 | + |
| 44 | +## Device Update REST APIs |
44 | 45 |
|
45 | 46 | Device Update uses Microsoft Entra ID for authentication to its REST APIs. To get started, you need to create and configure a client application.
|
46 | 47 |
|
47 | 48 | <a name='create-client-azure-ad-app'></a>
|
| 49 | +### Create a client Microsoft Entra app |
48 | 50 |
|
49 |
| -### Create client Microsoft Entra app |
50 |
| - |
51 |
| -To integrate an application or service with Microsoft Entra ID, first [register a client application with Microsoft Entra ID](../active-directory/develop/quickstart-register-app.md). Client application setup will vary depending on the authorization flow you'll need (users, applications or managed identities). For example, to call Device Update from: |
| 51 | +To integrate an application or service with Microsoft Entra ID, first [register a client application with Microsoft Entra ID](../active-directory/develop/quickstart-register-app.md). Client application setup varies depending on the authorization flow you need: users, applications, or managed identities. For example: |
52 | 52 |
|
53 |
| -* Mobile or desktop application, add **Mobile and desktop applications** platform with `https://login.microsoftonline.com/common/oauth2/nativeclient` for the Redirect URI. |
54 |
| -* Website with implicit sign-on, add **Web** platform and select **Access tokens (used for implicit flows)**. |
| 53 | +- To call Device Update from a mobile or desktop application, add **Mobile and desktop applications** platform with `https://login.microsoftonline.com/common/oauth2/nativeclient` for the redirect URI. |
| 54 | +- To call Device Update from a website with implicit sign-on, add **Web** platform and select **Access tokens (used for implicit flows)**. |
55 | 55 |
|
56 | 56 | >[!NOTE]
|
57 |
| ->Microsoft recommends that you use the most secure authentication flow available. Implicit flow authentication requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable. |
| 57 | +>Use the most secure authentication flow available. Implicit flow authentication requires a high degree of trust in the application, and carries risks that aren't present in other flows. You should use this flow only when other more secure flows, such as managed identities, aren't viable. |
58 | 58 |
|
59 | 59 | ### Configure permissions
|
60 | 60 |
|
61 |
| -Next, add permissions for calling Device Update to your app: |
| 61 | +Next, grant permissions to your app to call Device Update. |
62 | 62 |
|
63 | 63 | 1. Go to the **API permissions** page of your app and select **Add a permission**.
|
64 |
| -2. Go to **APIs my organization uses** and search for **Azure Device Update**. |
65 |
| -3. Select **user_impersonation** permission and select **Add permissions**. |
| 64 | +1. Go to **APIs my organization uses** and search for **Azure Device Update**. |
| 65 | +1. Select **user_impersonation** permission and select **Add permissions**. |
66 | 66 |
|
67 | 67 | ### Request authorization token
|
68 | 68 |
|
69 |
| -The Device Update REST API requires an OAuth 2.0 authorization token in the request header. The following sections show some examples of ways to request an authorization token. |
| 69 | +The Device Update REST API requires an OAuth 2.0 authorization token in the request header. The following sections show examples of some ways to request an authorization token. |
70 | 70 |
|
71 |
| -#### Using Azure CLI |
| 71 | +#### Azure CLI |
72 | 72 |
|
73 | 73 | ```azurecli
|
74 | 74 | az login
|
75 | 75 | az account get-access-token --resource 'https://api.adu.microsoft.com/'
|
76 | 76 | ```
|
77 | 77 |
|
78 |
| -#### Using PowerShell MSAL Library |
| 78 | +#### PowerShell MSAL Library |
79 | 79 |
|
80 |
| -[MSAL.PS](https://github.com/AzureAD/MSAL.PS) PowerShell module is a wrapper over [Microsoft Authentication Library for .NET (MSAL .NET)](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet). It supports various authentication methods. |
| 80 | +[MSAL.PS](https://github.com/AzureAD/MSAL.PS) PowerShell module is a wrapper over [Microsoft Authentication Library for .NET (MSAL .NET)](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) that supports various authentication methods. |
81 | 81 |
|
82 |
| -_Using user credentials_: |
| 82 | +- User credentials: |
83 | 83 |
|
84 |
| -```powershell |
85 |
| -$clientId = '<app_id>' |
86 |
| -$tenantId = '<tenant_id>' |
87 |
| -$authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
88 |
| -$Scope = 'https://api.adu.microsoft.com/user_impersonation' |
| 84 | + ```powershell |
| 85 | + $clientId = '<app_id>' |
| 86 | + $tenantId = '<tenant_id>' |
| 87 | + $authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
| 88 | + $Scope = 'https://api.adu.microsoft.com/user_impersonation' |
| 89 | + |
| 90 | + Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope |
| 91 | + ``` |
89 | 92 |
|
90 |
| -Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope |
91 |
| -``` |
| 93 | +- User credentials with device code: |
92 | 94 |
|
93 |
| -_Using user credentials with device code_: |
| 95 | + ```powershell |
| 96 | + $clientId = '<app_id>’ |
| 97 | + $tenantId = '<tenant_id>’ |
| 98 | + $authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
| 99 | + $Scope = 'https://api.adu.microsoft.com/user_impersonation' |
| 100 | + |
| 101 | + Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope -Interactive -DeviceCode |
| 102 | + ``` |
94 | 103 |
|
95 |
| -```powershell |
96 |
| -$clientId = '<app_id>’ |
97 |
| -$tenantId = '<tenant_id>’ |
98 |
| -$authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
99 |
| -$Scope = 'https://api.adu.microsoft.com/user_impersonation' |
100 |
| -
|
101 |
| -Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope -Interactive -DeviceCode |
102 |
| -``` |
| 104 | +- App credentials: |
103 | 105 |
|
104 |
| -_Using app credentials_: |
105 |
| - |
106 |
| -```powershell |
107 |
| -$clientId = '<app_id>’ |
108 |
| -$tenantId = '<tenant_id>’ |
109 |
| -$cert = '<client_certificate>' |
110 |
| -$authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
111 |
| -$Scope = 'https://api.adu.microsoft.com/.default' |
112 |
| -
|
113 |
| -Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope -ClientCertificate $cert |
114 |
| -``` |
| 106 | + ```powershell |
| 107 | + $clientId = '<app_id>’ |
| 108 | + $tenantId = '<tenant_id>’ |
| 109 | + $cert = '<client_certificate>' |
| 110 | + $authority = "https://login.microsoftonline.com/$tenantId/v2.0" |
| 111 | + $Scope = 'https://api.adu.microsoft.com/.default' |
| 112 | + |
| 113 | + Get-MsalToken -ClientId $clientId -TenantId $tenantId -Authority $authority -Scopes $Scope -ClientCertificate $cert |
| 114 | + ``` |
115 | 115 |
|
116 | 116 | ## Support for managed identities
|
117 | 117 |
|
118 |
| -Managed identities provide Azure services with an automatically managed identity in Microsoft Entra ID in a secure manner. This eliminates the needs for developers having to manage credentials by providing an identity. Device Update for IoT Hub supports system-assigned managed identities. |
| 118 | +Managed identities provide Azure services with secure, automatically managed Microsoft Entra ID identities. Managed identities eliminate the need for developers to manage credentials by providing identities. Device Update supports system-assigned managed identities. |
| 119 | + |
| 120 | +To add a system-assigned managed identity for Device Update: |
119 | 121 |
|
120 |
| -### System-assigned managed identity |
| 122 | +1. In the Azure portal, go to your Device Update account. |
| 123 | +1. In the left navigation, select **Settings** > **Identity**. |
| 124 | +1. Under **System assigned** on the **Identity** page, set **Status** to **On**. |
| 125 | +1. Select **Save**, and then select **Yes**. |
121 | 126 |
|
122 |
| -To add and remove a system-assigned managed identity in Azure portal: |
123 |
| -1. Sign in to the Azure portal and navigate to your desired Device Update for IoT Hub account. |
124 |
| -2. Navigate to Identity in your Device Update for IoT Hub portal |
125 |
| -3. Navigate to Identity in your IoT Hub portal |
126 |
| -4. Under System-assigned tab, select On and click Save. |
| 127 | +To add a system-assigned managed identity for IoT Hub: |
127 | 128 |
|
128 |
| -To remove system-assigned managed identity from a Device Update for IoT hub account, select Off and click Save. |
| 129 | +1. In the Azure portal, go to your IoT hub. |
| 130 | +1. In the left navigation, select **Security settings** > **Identity**. |
| 131 | +1. Under **System-assigned** on the **Identity** page, select **On** under **Status**. |
| 132 | +1. Select **Save**, and then select **Yes**. |
129 | 133 |
|
| 134 | +To remove system-assigned managed identity from a Device Update account or IoT hub, set or select **Off** on the **Identity** page, and then select **Save**. |
130 | 135 |
|
| 136 | +## Related content |
131 | 137 |
|
132 |
| -## Next Steps |
133 |
| -* [Create device update resources and configure access control roles](./create-device-update-account.md) |
| 138 | +- [Create Azure Device Update for IoT Hub resources](create-device-update-account.md) |
| 139 | +- [Configure access control for Device Update resources](configure-access-control-device-update.md) |
0 commit comments