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-configure-file-upload-cli.md
+18-28Lines changed: 18 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: kgremban
6
6
ms.author: kgremban
7
7
ms.service: azure-iot-hub
8
8
ms.topic: how-to
9
-
ms.date: 07/20/2021
9
+
ms.date: 12/05/2024
10
10
ms.custom: devx-track-azurecli
11
11
---
12
12
@@ -24,7 +24,7 @@ To use the [file upload functionality in IoT Hub](iot-hub-devguide-file-upload.m
24
24
25
25
* 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).
26
26
27
-
* An Azure Storage account. If you don't have an Azure Storage account, you can use the Azure CLI to create one. For more information, see [Create a storage account](../storage/common/storage-account-create.md).
27
+
* An Azure Storage account with a blob container. If you don't have an Azure Storage account, you can use the Azure CLI to create one. For more information, see [Create a storage account](../storage/common/storage-account-create.md).
@@ -54,40 +54,31 @@ Sign in to your Azure account and select your subscription. If you're using Azur
54
54
az account set --subscription {your subscription name or id}
55
55
```
56
56
57
-
## Retrieve your storage account details
57
+
## Configure storage account access
58
58
59
59
The following steps assume that you created your storage account using the **Resource Manager** deployment model, and not the **Classic** deployment model.
60
60
61
-
To configure file uploads from your devices, you need the connection string for an Azure Storage account. The storage account must be in the same subscription as your IoT hub. You also need the name of a blob container in the storage account. Use the following command to retrieve your storage account keys:
61
+
To configure file uploads from your devices, you need to give your IoT hub access permissions to the Azure Storage account. The storage account must be in the same subscription as your IoT hub. You also need the name of a blob container in the storage account.
62
62
63
-
```azurecli
64
-
az storage account show-connection-string --name {your storage account name} \
The connection string will be similar to the following output:
63
+
You can use either key-based or identity-based authentication to provide access permissions. Microsoft recommends identity-based authentication as a more secure option.
64
+
65
+
### Key-based authentication
66
+
67
+
For key-based authentication, provide the connection string for your storage account. Use the [az storage account show-connection-string](/cli/azure/storage/account#az-storage-account-show-connection-string) command to retrieve your storage account keys.
68
+
69
+
Make a note of the `connectionString` value. The connection string looks similar to the following output:
Make a note of the `connectionString` value. You need it in the following steps.
77
+
### Identity-based authentication
76
78
77
-
You can either use an existing blob container for your file uploads or create a new one:
79
+
You can use system-assigned managed identities or user-assigned managed identities for identity-based authentication. For more information, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md).
78
80
79
-
* To list the existing blob containers in your storage account, use the following command:
80
-
81
-
```azurecli
82
-
az storage container list --connection-string "{your storage account connection string}"
83
-
```
84
-
85
-
* To create a blob container in your storage account, use the following command:
86
-
87
-
```azurecli
88
-
az storage container create --name {container name} \
Use the [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command to assign a role to your managed identity. For more information, see [Assign an Azure role for access to blob data](../storage/blobs/assign-azure-role-data-access.md).
91
82
92
83
## Configure your IoT hub
93
84
@@ -107,12 +98,11 @@ The configuration requires the following values:
107
98
108
99
***File notification lock duration**: The lock duration for the file notification queue. Set to 60 seconds by default.
109
100
110
-
* **Authentication type**: The type of authentication for IoT Hub to use with Azure Storage. This setting determines how your IoT hub authenticates and authorizes with Azure Storage. The default is key-based authentication; however, system-assigned and user-assigned managed identities can also be used. Managed identities provide Azure services with an automatically managed identity in Microsoft Entra ID in a secure manner. To learn how to configure managed identities on your IoT hub and Azure Storage account, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md). Once configured, you can set one of your managed identities to use for authentication with Azure storage.
101
+
***Authentication type**: The type of authentication for IoT Hub to use with Azure Storage. This setting determines how your IoT hub authenticates and authorizes with Azure Storage. The default is key-based authentication; however, the system-assigned or user-assigned managed identity authentication options are recommended. Managed identities provide Azure services with an automatically managed identity in Microsoft Entra ID in a secure manner.
111
102
112
103
> [!NOTE]
113
104
> The authentication type setting configures how your IoT hub authenticates with your Azure Storage account. Devices always authenticate with Azure Storage using the SAS URI that they get from the IoT hub.
114
105
115
-
116
106
The following commands show how to configure the file upload settings on your IoT hub. These commands are shown separately for clarity, but, typically, you would issue a single command with all the required parameters for your scenario. Include quotes where they appear in the command line. Don't include the braces. More detail about each parameter can be found in the Azure CLI documentation for the [az iot hub update](/cli/azure/iot/hub#az-iot-hub-update) command.
117
107
118
108
The following command configures the storage account and blob container.
The following command configures authentication using the IoT hub's system-assigned managed identity. Before you can run this command, you need to enable the system-assigned managed identity for your IoT hub and grant it the correct RBAC role on your Azure Storage account. To learn how, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md).
140
+
The following command configures authentication using the IoT hub's system-assigned managed identity. Before you can run this command, you need to enable the system-assigned managed identity for your IoT hub and grant it the correct role-based access control role on your Azure Storage account. To learn how, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md).
151
141
152
142
```azurecli
153
143
az iot hub update --name {your iot hub name} \
154
144
--fileupload-storage-auth-type identityBased \
155
145
--fileupload-storage-identity [system]
156
146
```
157
147
158
-
The following commands retrieve the user-assigned managed identities configured on your IoT hub and configure authentication with one of them. Before you can use a user-assigned managed identity to authenticate, it must be configured on your IoT hub and granted an appropriate RBAC role on your Azure Storage account. For more detail and steps, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md).
148
+
The following commands retrieve the user-assigned managed identities configured on your IoT hub and configure authentication with one of them. Before you can use a user-assigned managed identity to authenticate, it must be configured on your IoT hub and granted an appropriate role-based access control role on your Azure Storage account. For more detail and steps, see [IoT Hub support for managed identities](./iot-hub-managed-identity.md).
159
149
160
150
To query for user-assigned managed identities on your IoT hub, use the [az iot hub identity show](/cli/azure/iot/hub/identity#az-iot-hub-identity-show) command.
0 commit comments