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
+57-13Lines changed: 57 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
---
2
2
title: Create an Azure IoT hub
3
3
titleSuffix: Azure IoT Hub
4
-
description: How to create, manage, and delete Azure IoT hubs through the Azure portaland CLI. Includes information about retrieving the service connection string.
4
+
description: How to create, manage, and delete Azure IoT hubs through the Azure portal, CLI, and PowerShell. Includes information about retrieving the service connection string.
5
5
author: kgremban
6
6
7
7
ms.author: kgremban
8
8
ms.service: iot-hub
9
9
ms.topic: how-to
10
-
ms.date: 07/03/2024
10
+
ms.date: 07/10/2024
11
11
ms.custom: ['Role: Cloud Development']
12
12
---
13
13
@@ -29,10 +29,20 @@ Prepare the following prerequisites, depending on which tool you use.
29
29
30
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
31
32
-
```azurecli
32
+
```azurecli-interactive
33
33
az group create --name <RESOURCE_GROUP_NAME> --location <REGION>
34
34
```
35
35
36
+
### [Azure PowerShell](#tab/powershell)
37
+
38
+
* Azure PowerShell installed on your development machine. If you don't have Azure PowerShell, follow the steps to [Install Azure PowerShell](/powershell/azure/install-azure-powershell).
39
+
40
+
* A resource group in your Azure subscription. If you want to create a new resource group, use the [New-AzResourceGroup](/powershell/module/az.Resources/New-azResourceGroup) command:
@@ -43,8 +53,6 @@ Prepare the following prerequisites, depending on which tool you use.
43
53
44
54
### [Azure CLI](#tab/cli)
45
55
46
-
Use the Azure CLI to create a resource group and then add an IoT hub.
47
-
48
56
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:
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/).
57
65
66
+
### [Azure PowerShell](#tab/powershell)
67
+
68
+
Use the [New-AzIotHub](/powershell/module/az.IotHub/New-azIotHub) command to create an IoT hub in your resource group. The name of the IoT hub must be globally unique. For example:
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/).
81
+
58
82
---
59
83
60
84
## Connect to an IoT hub
@@ -81,15 +105,29 @@ To get the IoT Hub connection string for the **service** policy, follow these st
81
105
82
106
#### [Azure CLI](#tab/cli)
83
107
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:
108
+
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 grants the service policy permissions:
85
109
86
110
```azurecli-interactive
87
-
az iot hub connection-string show --hub-name YOUR_IOT_HUB_NAME --policy-name service
111
+
az iot hub connection-string show --hub-name <YOUR_IOT_HUB_NAME> --policy-name service
112
+
```
113
+
114
+
The service connection string should look similar to the following example:
Use the [Get-AzIotHubConnectionString](/powershell/module/az.iothub/get-aziothubconnectionstring) command to get a connection string for your IoT hub that grants the service policy permissions.
@@ -117,21 +155,27 @@ To delete an IoT hub, run the [az iot hub delete](/cli/azure/iot/hub#az-iot-hub-
117
155
az iot hub delete --name <IOT_HUB_NAME> --resource-group <RESOURCE_GROUP_NAME>
118
156
```
119
157
158
+
### [Azure PowerShell](#tab/powershell)
159
+
160
+
To delete the IoT hub, use the [Remove-AzIotHub](/powershell/module/az.iothub/remove-aziothub) command.
161
+
162
+
```azurepowershell-interactive
163
+
Remove-AzIotHub `
164
+
-ResourceGroupName MyIoTRG1 `
165
+
-Name MyTestIoTHub
166
+
```
167
+
120
168
---
121
169
122
170
## Other tools for managing IoT hubs
123
171
124
172
In addition to the Azure portal and CLI, the following tools are available to help you work with IoT hubs in whichever way supports your scenario:
125
173
126
-
***PowerShell cmdlets**
127
-
128
-
Use the [Az.IoTHub](/powershell/module/az.iothub) set of commands.
129
-
130
174
***IoT Hub resource provider REST API**
131
175
132
176
Use the [IoT Hub Resource](/rest/api/iothub/iot-hub-resource) set of operations.
133
177
134
-
***Azure resource manager templates, Bicep, or Terraform**
178
+
***Azure resource manager templates, Bicep, or Terraform**
135
179
136
180
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).
0 commit comments