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/create-hub.md
+33-29Lines changed: 33 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ author: kgremban
7
7
ms.author: kgremban
8
8
ms.service: iot-hub
9
9
ms.topic: how-to
10
-
ms.date: 06/10/2024
10
+
ms.date: 07/03/2024
11
11
ms.custom: ['Role: Cloud Development']
12
12
---
13
13
@@ -17,7 +17,23 @@ This article describes how to create and manage an IoT hub.
17
17
18
18
## Prerequisites
19
19
20
-
* Depending on which tool you use, either have access to the [Azure portal](https://portal.azure.com) or [install the Azure CLI](/cli/azure/install-azure-cli).
20
+
Prepare the following prerequisites, depending on which tool you use.
21
+
22
+
### [Azure portal](#tab/portal)
23
+
24
+
* Access to the [Azure portal](https://portal.azure.com).
25
+
26
+
### [Azure CLI]()
27
+
28
+
* The Azure CLI installed on your development machine. If you don't have the Azure CLI, follow the steps to [Install the Azure CLI](/cli/azure/install-azure-cli).
29
+
30
+
* A resource group in your Azure subscription. If you want to create a new resource group, use the [az group create](/cli/azure/group#az-group-create) command:
31
+
32
+
```azurecli
33
+
az group create --name <RESOURCE_GROUP_NAME> --location <REGION>
34
+
```
35
+
36
+
---
21
37
22
38
## Create an IoT hub
23
39
@@ -29,16 +45,15 @@ This article describes how to create and manage an IoT hub.
29
45
30
46
Use the Azure CLI to create a resource group and then add an IoT hub.
31
47
32
-
Use the [iz iot hub create](/cli/azure/iot/hub#az-iot-hub-create) command to create an IoT hub in your resource group, using a globally unique name for your IoT hub. For example:
48
+
Use the [az iot hub create](/cli/azure/iot/hub#az-iot-hub-create) command to create an IoT hub in your resource group, using a globally unique name for your IoT hub. For example:
33
49
34
50
```azurecli-interactive
35
-
az iot hub create --name <NEW_NAME_FOR_YOUR_IOT_HUB> \
36
-
--resource-group <RESOURCE_GROUP_NAME> --sku S1
51
+
az iot hub create --name <NEW_NAME_FOR_YOUR_IOT_HUB> --resource-group <RESOURCE_GROUP_NAME> --sku S1
The previous command creates an IoT hub in the S1 pricing tier for which you're billed. For more information, see [Azure IoT Hub pricing](https://azure.microsoft.com/pricing/details/iot-hub/).
56
+
The previous command creates an IoT hub in the S1 pricing tier. For more information, see [Azure IoT Hub pricing](https://azure.microsoft.com/pricing/details/iot-hub/).
42
57
43
58
---
44
59
@@ -48,23 +63,14 @@ Provide access permissions to applications and services that use IoT Hub functio
48
63
49
64
### Connect with a connection string
50
65
51
-
Connection strings are an easy way to get started with IoT Hub, and are used in many samples and tutorials, but aren't recommended for production scenarios.
66
+
Connection strings are tokens that grant devices and services permissions to connect to IoT Hub based on shared access policies. Connection strings are an easy way to get started with IoT Hub, and are used in many samples and tutorials, but aren't recommended for production scenarios.
52
67
53
-
Shared access policies define permissions for devices and services to connect to IoT Hub. The built-in policies provide one or more of the following permissions. You should always provide the least necessary permissions for a given scenario.
54
-
55
-
* The **Registry Read** and **Registry Write** permissions grant read and write access rights to the identity registry. These permissions are used by back-end cloud services to manage device identities.
56
-
57
-
* The **Service Connect** permission grants permission to access service endpoints. This permission is used by back-end cloud services to send and receive messages from devices. It's also used to update and read device twin and module twin data.
58
-
59
-
* The **Device Connect** permission grants permissions for sending and receiving messages using the IoT Hub device-side endpoints. This permission is used by devices to send and receive messages from an IoT hub or update and read device twin and module twin data. It's also used for file uploads.
60
-
61
-
For information about the access granted by specific permissions, see [IoT Hub permissions](./iot-hub-dev-guide-sas.md#access-control-and-permissions).
68
+
For most sample scenarios, the **service** policy is sufficient. The service policy grants **Service Connect** permissions to access service endpoints. For more information about the other built-in shared access policies, see [IoT Hub permissions](./iot-hub-dev-guide-sas.md#access-control-and-permissions).
62
69
70
+
To get the IoT Hub connection string for the **service** policy, follow these steps:
63
71
64
72
#### [Azure portal](#tab/portal)
65
73
66
-
To get the IoT Hub connection string for the **service** policy, follow these steps:
67
-
68
74
1. In the [Azure portal](https://portal.azure.com), select **Resource groups**. Select the resource group where your hub is located, and then select your hub from the list of resources.
69
75
70
76
1. On the left-side pane of your IoT hub, select **Shared access policies**.
@@ -73,10 +79,9 @@ To get the IoT Hub connection string for the **service** policy, follow these st
73
79
74
80
1. Copy the **Primary connection string** and save the value.
75
81
76
-
77
82
#### [Azure CLI](#tab/cli)
78
83
79
-
IoT hubs are created with several default access policies. One such policy is the **service** policy, which provides sufficient permissions for a service to read and write the IoT hub's endpoints. Run the following command to get a connection string for your IoT hub that adheres to the service policy:
84
+
Use the [az iot hub connection-string show](/cli/azure/iot/hub/connection-string#az-iot-hub-connection-string-show) command to get a connection string for your IoT hub that adheres to the service policy:
80
85
81
86
```azurecli-interactive
82
87
az iot hub connection-string show --hub-name YOUR_IOT_HUB_NAME --policy-name service
@@ -92,11 +97,11 @@ The service connection string should look similar to the following example:
92
97
93
98
### Connect with role assignments
94
99
95
-
In production scenarios, we recommend using Microsoft Entra ID and Azure role-based access control (Azure RBAC) for connecting to IoT Hub. For more information, see [Control access to IoT Hub by using Microsoft Entra ID](./authenticate-authorize-azure-ad.md).
100
+
Authenticating access by using Microsoft Entra ID and controlling permissions by using Azure role-based access control (RBAC) provides improved security and ease of use over security tokens. To minimize potential security issues inherent in security tokens, we recommend that you enforce Microsoft Entra authentication whenever possible. For more information, see [Control access to IoT Hub by using Microsoft Entra ID](./authenticate-authorize-azure-ad.md).
96
101
97
102
## Delete an IoT hub
98
103
99
-
When you delete an IoT hub, you lose the associated device identity registry. Any registered devices will need to be registered to a new IoT hub to continue sending data. If you want to move or upgrade an IoT hub, or delete an IoT hub but keep the devices, consider [migrating an IoT hub using the Azure CLI](./migrate-hub-state-cli.md).
104
+
When you delete an IoT hub, you lose the associated device identity registry. If you want to move or upgrade an IoT hub, or delete an IoT hub but keep the devices, consider [migrating an IoT hub using the Azure CLI](./migrate-hub-state-cli.md).
100
105
101
106
### [Azure portal](#tab/portal)
102
107
@@ -106,11 +111,10 @@ To delete an IoT hub, open your IoT hub in the Azure portal, then choose **Delet
106
111
107
112
### [Azure CLI](#tab/cli)
108
113
109
-
To [delete an IoT hub](/cli/azure/iot/hub#az-iot-hub-delete), run the following command:
114
+
To delete an IoT hub, run the [az iot hub delete](/cli/azure/iot/hub#az-iot-hub-delete) command:
110
115
111
116
```azurecli-interactive
112
-
az iot hub delete --name {your iot hub name} -\
113
-
-resource-group {your resource group name}
117
+
az iot hub delete --name <IOT_HUB_NAME> --resource-group <RESOURCE_GROUP_NAME>
114
118
```
115
119
116
120
---
@@ -121,16 +125,16 @@ In addition to the Azure portal and CLI, the following tools are available to he
121
125
122
126
***PowerShell cmdlets**
123
127
124
-
Use the [Az.IoTHub](/powershell/module/az.iothub) set of commands to create and manage IoT hubs.
128
+
Use the [Az.IoTHub](/powershell/module/az.iothub) set of commands.
125
129
126
130
***IoT Hub resource provider REST API**
127
131
128
-
Use the [IoT Hub Resource](/rest/api/iothub/iot-hub-resource) set of operations to create and manage IoT hubs.
132
+
Use the [IoT Hub Resource](/rest/api/iothub/iot-hub-resource) set of operations.
129
133
130
134
***Azure resource manager templates, Bicep, or Terraform**
131
135
132
-
Use the [Microsoft.Devices/IoTHubs](/azure/templates/microsoft.devices/iothubs) resource type to create and manage IoT hubs. For examples, see [IoT Hub sample templates](/samples/browse/?terms=iot%20hub&languages=bicep%2Cjson)
136
+
Use the [Microsoft.Devices/IoTHubs](/azure/templates/microsoft.devices/iothubs) resource type. For examples, see [IoT Hub sample templates](/samples/browse/?terms=iot%20hub&languages=bicep%2Cjson).
133
137
134
138
***Visual Studio Code**
135
139
136
-
Use the [Azure IoT Hub extension for Visual Studio Code](./reference-iot-hub-extension.md) to create and manage IoT hubs.
140
+
Use the [Azure IoT Hub extension for Visual Studio Code](./reference-iot-hub-extension.md).
0 commit comments