You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-managed-identity.md
+27-26Lines changed: 27 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,21 +6,21 @@ author: SoniaLopezBravo
6
6
ms.author: sonialopez
7
7
ms.service: azure-iot-hub
8
8
ms.topic: how-to
9
-
ms.date: 08/23/2024
9
+
ms.date: 07/01/2025
10
10
ms.custom: subject-rbac-steps
11
11
---
12
12
13
13
# IoT Hub support for managed identities
14
14
15
-
Managed identities provide Azure services with an automatically managed identity in Microsoft Entra ID in a secure manner. This eliminates the need for developers having to manage credentials by providing an identity. There are two types of managed identities: system-assigned and user-assigned. IoT Hub supports both.
15
+
Managed identities provide Azure services with an automatically managed identity in Microsoft Entra ID in a secure manner. This feature eliminates the need for developers having to manage credentials by providing an identity. There are two types of managed identities: system-assigned and user-assigned. IoT Hub supports both.
16
16
17
17
In IoT Hub, managed identities can be used to connect IoT Hub to other Azure services for features such as [message routing](iot-hub-devguide-messages-d2c.md), [file upload](iot-hub-devguide-file-upload.md), and [bulk device import/export](iot-hub-bulk-identity-mgmt.md). In this article, you learn how to use system-assigned and user-assigned managed identities in your IoT hub for different functionalities.
18
18
19
19
## Prerequisites
20
20
21
21
- Understand the differences between *system-assigned* and *user-assigned* managed identity in [What are managed identities for Azure resources?](/entra/identity/managed-identities-azure-resources/overview)
22
22
23
-
- An IoT hub in your Azure subscription. If you don't have a hub yet, you can follow the steps in [Create an IoT hub](create-hub.md).
23
+
- An IoT hub in your Azure subscription. If you don't have a hub yet, you can follow the steps in [Create an IoT hub](create-hub.md#create-an-iot-hub).
24
24
25
25
## System-assigned managed identity
26
26
@@ -42,7 +42,7 @@ You can enable or disable system-assigned managed identity in Azure portal
42
42
43
43
You can enable system-assigned managed identity at hub creation time using ARM template
44
44
45
-
To enable the system-assigned managed identity in your IoT hub at resource provisioning time, use the Azure Resource Manager (ARM) template below.
45
+
To enable the system-assigned managed identity in your IoT hub at resource provisioning time, use the following Azure Resource Manager (ARM) template.
46
46
47
47
```json
48
48
{
@@ -111,7 +111,7 @@ To enable the system-assigned managed identity in your IoT hub at resource provi
111
111
}
112
112
```
113
113
114
-
After substituting the values for your resource `name`, `location`, `SKU.name` and `SKU.tier`, you can use Azure CLI to deploy the resource in an existing resource group using:
114
+
After substituting the values for your resource `name`, `location`, `SKU.name`, and `SKU.tier`, you can use Azure CLI to deploy the resource in an existing resource group using:
115
115
116
116
```azurecli-interactive
117
117
az deployment group create --name <deployment-name> --resource-group <resource-group-name> --template-file <template-file.json> --parameters iotHubName=<valid-iothub-name> skuName=<sku-name> skuTier=<sku-tier> location=<any-of-supported-regions>
@@ -132,11 +132,12 @@ az resource show --resource-type Microsoft.Devices/IotHubs --name <iot-hub-resou
132
132
In this section, you learn how to add and remove a user-assigned managed identity from an IoT hub using Azure portal.
133
133
134
134
1. First you need to create a user-assigned managed identity as a standalone resource. To do so, you can follow the instructions in [Manage user-assigned managed identities](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities).
135
-
2. Go to your IoT hub, navigate to the **Identity** in the IoT Hub portal.
136
-
3. Under **User-Assigned** tab, click **Associate a user-assigned managed identity**. Choose the user-assigned managed identity you want to add to your hub and then click **Select**.
137
-
4. You can remove a user-assigned identity from an IoT hub. Choose the user-assigned identity you want to remove, and click **Remove** button. Note you are only removing it from IoT hub, and this removal does not delete the user-assigned identity as a resource. To delete the user-assigned identity as a resource, follow the instructions in [Manage user-assigned managed identities](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities).
135
+
2. Go to your IoT hub, then select **Identity** under **Security settings** from the service menu in Azure portal.
136
+
3. Under the **User-Assigned** tab, select **Associate a user-assigned managed identity**. Choose the user-assigned managed identity you want to add to your hub and then select **Add**.
138
137
139
-
:::image type="content" source="./media/iot-hub-managed-identity/user-assigned.png" alt-text="Screenshot showing how to add user-assigned managed identity for an IoT hub." lightbox="./media/iot-hub-managed-identity/user-assigned.png":::
138
+
:::image type="content" source="./media/iot-hub-managed-identity/user-assigned.png" alt-text="Screenshot showing how to add a user-assigned managed identity for an IoT hub." lightbox="./media/iot-hub-managed-identity/user-assigned.png":::
139
+
140
+
4. You can remove a user-assigned identity from an IoT hub. Choose the user-assigned identity you want to remove, and select **Remove**. You're removing it only from your IoT hub, and this removal doesn't delete the user-assigned identity as a resource. To delete the user-assigned identity as a resource, follow the instructions in [Manage user-assigned managed identities](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities).
140
141
141
142
### [Azure Resource Manager](#tab/arm)
142
143
@@ -269,10 +270,10 @@ In this section, we use the [message routing](iot-hub-devguide-messages-d2c.md)
269
270
270
271
For more information about role assignments, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml).
271
272
272
-
1. If you need to restrict the connectivity to your custom endpoint through a VNet, you need to turn on the trusted Microsoft first party exception, to give your IoT hub access to the specific endpoint. For example, if you're adding an event hub custom endpoint, navigate to the **Firewalls and virtual networks** tab in your event hub and enable **Allow access from selected networks** option. Under the **Exceptions** list, check the box for **Allow trusted Microsoft services to access event hubs**. Click the**Save** button. This also applies to storage account and service bus. Learn more about [IoT Hub support for virtual networks](./virtual-network-support.md).
273
+
1. If you need to restrict the connectivity to your custom endpoint through a virtual network, you need to turn on the trusted Microsoft first party exception, to give your IoT hub access to the specific endpoint. For example, if you're adding an event hub custom endpoint, navigate to the **Firewalls and virtual networks** tab in your event hub and enable **Allow access from selected networks** option. Under the **Exceptions** list, check the box for **Allow trusted Microsoft services to access event hubs**, then select**Save**. This requirement also applies to storage account and service bus. Learn more about [IoT Hub support for virtual networks with Azure Private Link](./virtual-network-support.md).
273
274
274
275
> [!NOTE]
275
-
> You need to complete above steps to assign the managed identity the right access before adding the event hub as a custom endpoint in IoT Hub. Please wait a few minutes for the role assignment to propagate.
276
+
> You need to complete above steps to assign the managed identity the right access before adding the event hub as a custom endpoint in IoT Hub. Wait a few minutes for the role assignment to propagate.
276
277
277
278
1. Next, go to your IoT hub. In your hub, navigate to **Message Routing**, then select **Add**.
For more information about role assignments, see [Assign Azure roles using the Azure portal](../role-based-access-control/role-assignments-portal.yml).
324
325
325
-
If you need to restrict the connectivity to your storage account through a VNet, you need to turn on the trusted Microsoft first party exception, to give your IoT hub access to the storage account. On your storage account resource page, navigate to the **Firewalls and virtual networks** tab and enable **Allow access from selected networks** option. Under the **Exceptions** list, check the box for **Allow trusted Microsoft services to access this storage account**. Click the **Save** button. Learn more about [IoT Hub support for virtual networks](./virtual-network-support.md).
326
+
If you need to restrict the connectivity to your storage account through a virtual network, you need to turn on the trusted Microsoft first party exception, to give your IoT hub access to the storage account. On your storage account resource page, navigate to the **Firewalls and virtual networks** tab and enable **Allow access from selected networks** option. Under the **Exceptions** list, check the box for **Allow trusted Microsoft services to access this storage account**, and then select **Save**. Learn more about [IoT Hub support for virtual networks with Azure Private Link](./virtual-network-support.md).
326
327
327
328
> [!NOTE]
328
-
> You need to complete above steps to assign the managed identity the right access before saving the storage account in IoT Hub for file upload using the managed identity. Please wait a few minutes for the role assignment to propagate.
329
+
> You need to complete above steps to assign the managed identity the right access before saving the storage account in IoT Hub for file upload using the managed identity. Wait a few minutes for the role assignment to propagate.
329
330
330
331
1. On your IoT hub's resource page, navigate to **File upload** tab.
331
332
332
-
1. On the page that shows up, select the container that you intend to use in your blob storage, configure the **File notification settings, SAS TTL, Default TTL, and Maximum delivery count** as desired. Choose the preferred authentication type, and click**Save**. If you get an error at this step, temporarily set your storage account to allow access from **All networks**, then try again. You can configure firewall on the storage account once the File upload configuration is complete.
333
+
1. On the page that shows up, select the container that you intend to use in your blob storage, configure the **File notification settings, SAS TTL, Default TTL, and Maximum delivery count** as desired. Choose the preferred authentication type, and select**Save**. If you get an error at this step, temporarily set your storage account to allow access from **All networks**, then try again. You can configure firewall on the storage account once the File upload configuration is complete.
333
334
334
335
:::image type="content" source="./media/iot-hub-managed-identity/file-upload.png" alt-text="Screen shot that shows file upload with msi.":::
335
336
336
337
> [!NOTE]
337
-
> In the file upload scenario, both hub and your device need to connect with your storage account. The steps above are for connecting your IoT hub to your storage account with desired authentication type. You still need to connect your device to storage using the SAS URI. Today the SAS URI is generated using connection string. We'll add support to generate SAS URI with managed identity soon. Please follow the steps in [file upload](iot-hub-devguide-file-upload.md).
338
+
> In the file upload scenario, both hub and your device need to connect with your storage account. The previous steps are for connecting your IoT hub to your storage account with desired authentication type. You must connect your device to storage using the SAS URI. Currently, the SAS URI is generated using the connection string. Follow the steps in [Upload files with IoT Hub](iot-hub-devguide-file-upload.md).
338
339
339
340
## Configure bulk device import/export with managed identities
340
341
341
-
IoT Hub supports the functionality to [import/export device information in bulk](iot-hub-bulk-identity-mgmt.md) from or to a customer-provided storage blob. This functionality requires connectivity from IoT Hub to the storage account.
342
+
IoT Hub supports the functionality to [import and export device information in bulk](iot-hub-bulk-identity-mgmt.md) from or to a customer-provided storage blob. This functionality requires connectivity from IoT Hub to the storage account.
342
343
343
344
1. In the Azure portal, navigate to your storage account.
344
345
@@ -362,7 +363,7 @@ IoT Hub supports the functionality to [import/export device information in bulk]
362
363
363
364
### Using REST API or SDK for import and export jobs
364
365
365
-
You can now use the Azure IoT REST APIs for creating import and export jobs. You will need to provide the following properties in the request body:
366
+
You can now use the Azure IoT REST APIs for creating import and export jobs. You need to provide the following properties in the request body:
366
367
367
368
-**storageAuthenticationType**: Set the value to **identityBased**.
368
369
-**inputBlobContainerUri**: Set this property only in the import job.
@@ -430,11 +431,11 @@ result = iothub_job_manager.create_import_export_job(JobProperties(
430
431
431
432
> [!NOTE]
432
433
>
433
-
> - If **storageAuthenticationType** is set to **identityBased** and **userAssignedIdentity** property is not **null**, the jobs will use the specified user-assigned managed identity.
434
-
> - If the IoT hub is not configured with the user-assigned managed identity specified in **userAssignedIdentity**, the job will fail.
435
-
> - If **storageAuthenticationType** is set to **identityBased** the **userAssignedIdentity** property is null, the jobs will use system-assigned identity.
436
-
> - If the IoT hub is not configured with the user-assigned managed identity, the job will fail.
437
-
> - If **storageAuthenticationType** is set to **identityBased** and neither **user-assigned**nor**system-assigned** managed identities are configured on the hub, the job will fail.
434
+
> - If **storageAuthenticationType** is set to **identityBased** and **userAssignedIdentity** property isn't **null**, the jobs use the specified user-assigned managed identity.
435
+
> - If the IoT hub isn't configured with the user-assigned managed identity specified in **userAssignedIdentity**, the job fails.
436
+
> - If **storageAuthenticationType** is set to **identityBased** the **userAssignedIdentity** property is null, the jobs use system-assigned identity.
437
+
> - If the IoT hub isn't configured with the user-assigned managed identity, the job fails.
438
+
> - If **storageAuthenticationType** is set to **identityBased** and **user-assigned**or**system-assigned** managed identities aren't configured on the hub, the job fails.
438
439
439
440
## SDK samples
440
441
@@ -444,8 +445,8 @@ result = iothub_job_manager.create_import_export_job(JobProperties(
444
445
445
446
## Next steps
446
447
447
-
Use the links below to learn more about IoT Hub features:
448
+
Use the following links to learn more about IoT Hub features:
0 commit comments