Skip to content

Commit 0111efe

Browse files
authored
Merge pull request #278857 from kgremban/jun20-hubcreate
Consolidate IoT Hub Create docs
2 parents 6f275cb + 0709671 commit 0111efe

File tree

56 files changed

+300
-627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+300
-627
lines changed

articles/iot-hub/.openpublishing.redirection.iot-hub.json

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@
307307
},
308308
{
309309
"source_path_from_root": "/articles/iot-hub/iot-hub-create-using-cli-nodejs.md",
310-
"redirect_url": "/azure/iot-hub/iot-hub-create-using-cli",
311-
"redirect_document_id": true
310+
"redirect_url": "/azure/iot-hub/create-hub",
311+
"redirect_document_id": false
312312
},
313313
{
314314
"source_path_from_root": "/articles/iot-hub/iot-hub-device-management-iothub-explorer.md",
@@ -1430,9 +1430,39 @@
14301430
"redirect_url": "/azure/iot-hub/reference-iot-hub-extension",
14311431
"redirect_document_id": false
14321432
},
1433+
{
1434+
"source_path_from_root": "/articles/iot-hub/iot-hub-create-through-portal.md",
1435+
"redirect_url": "/azure/iot-hub/create-hub",
1436+
"redirect_document_id": true
1437+
},
1438+
{
1439+
"source_path_from_root": "/articles/iot-hub/iot-hub-create-using-cli.md",
1440+
"redirect_url": "/azure/iot-hub/create-hub",
1441+
"redirect_document_id": false
1442+
},
1443+
{
1444+
"source_path_from_root": "/articles/iot-hub/iot-hub-create-using-powershell.md",
1445+
"redirect_url": "/azure/iot-hub/create-hub",
1446+
"redirect_document_id": false
1447+
},
1448+
{
1449+
"source_path_from_root": "/articles/iot-hub/iot-hub-create-use-iot-toolkit.md",
1450+
"redirect_url": "/azure/iot-hub/reference-iot-hub-extension",
1451+
"redirect_document_id": false
1452+
},
1453+
{
1454+
"source_path_from_root": "/articles/iot-hub/iot-hub-rm-rest.md",
1455+
"redirect_url": "/azure/iot-hub/create-hub",
1456+
"redirect_document_id": false
1457+
},
14331458
{
14341459
"source_path_from_root": "/articles/iot-hub/iot-hub-rm-template.md",
1435-
"redirect_url": "/azure/iot-hub/iot-hub-rm-template-powershell",
1460+
"redirect_url": "/azure/iot-hub/create-hub",
1461+
"redirect_document_id": false
1462+
},
1463+
{
1464+
"source_path_from_root": "/articles/iot-hub/iot-hub-rm-template-powershell.md",
1465+
"redirect_url": "/azure/iot-hub/create-hub",
14361466
"redirect_document_id": false
14371467
},
14381468
{

articles/iot-hub/TOC.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,25 +216,8 @@
216216
- name: Manage
217217
items:
218218
- name: Create an IoT hub
219-
items:
220-
- name: Use Azure portal
221-
displayName: create IoT Hub, register device, message routing, delete IoT hub
222-
href: iot-hub-create-through-portal.md
223-
- name: Use Visual Studio Code
224-
displayName: create IoT Hub, register device, message routing, delete IoT hub
225-
href: iot-hub-create-use-iot-toolkit.md
226-
- name: Use Azure PowerShell
227-
displayName: create IoT Hub, register device, message routing, delete IoT hub
228-
href: iot-hub-create-using-powershell.md
229-
- name: Use Azure CLI
230-
displayName: create IoT Hub, register device, message routing, delete IoT hub, az iot hub create
231-
href: iot-hub-create-using-cli.md
232-
- name: Use the REST API
233-
displayName: create IoT Hub, register device, message routing, delete IoT hub, Azure Resource Manager
234-
href: iot-hub-rm-rest.md
235-
- name: Use a template from Azure PowerShell
236-
displayName: create IoT Hub, register device, message routing, delete IoT hub, Azure Resource Manager
237-
href: iot-hub-rm-template-powershell.md
219+
displayName: create IoT Hub, delete IoT hub, portal, CLI
220+
href: create-hub.md
238221
- name: Create and connect a device
239222
href: create-connect-device.md
240223
- name: Create message routes and endpoints

articles/iot-hub/create-connect-device.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Create a device identity for your device to connect to Azure IoT Hub. This artic
1616

1717
## Prerequisites
1818

19-
* An IoT hub in your subscription. If you don't have an IoT hub, follow the steps in [create an IoT hub](./iot-hub-create-through-portal.md).
19+
* 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).
2020

2121
* 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).
2222

@@ -157,8 +157,12 @@ If you want to keep a device in your IoT hub's identity registry, but want to pr
157157

158158
* To prevent a device from connecting, set the **Enable connection to IoT Hub** parameter to **Disable**.
159159

160+
:::image type="content" source="./media/create-connect-device/disable-device.png" alt-text="Screenshot that shows disabling a device in the Azure portal.":::
161+
160162
* To completely remove a device from your IoT hub's identity registry, select **Delete**.
161163

164+
:::image type="content" source="./media/create-connect-device/delete-device.png" alt-text="Screenshot that shows deleting a device in the Azure portal.":::
165+
162166
### [Azure CLI](#tab/cli)
163167

164168
To disable a device, use the [az iot hub device-identity update](/cli/azure/iot/hub/device-identity#az-iot-hub-device-identity-update) command and change the `status` of the device. For example:

articles/iot-hub/create-hub.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
title: Create an Azure IoT hub
3+
titleSuffix: Azure IoT Hub
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+
author: kgremban
6+
7+
ms.author: kgremban
8+
ms.service: iot-hub
9+
ms.topic: how-to
10+
ms.date: 07/10/2024
11+
ms.custom: ['Role: Cloud Development']
12+
---
13+
14+
# Create and manage Azure IoT hubs
15+
16+
This article describes how to create and manage an IoT hub.
17+
18+
## Prerequisites
19+
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](#tab/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-interactive
33+
az group create --name <RESOURCE_GROUP_NAME> --location <REGION>
34+
```
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:
41+
42+
```azurepowershell-interactive
43+
New-AzResourceGroup -Name <RESOURCE_GROUP_NAME> -Location "<REGION>"
44+
```
45+
46+
---
47+
48+
## Create an IoT hub
49+
50+
### [Azure portal](#tab/portal)
51+
52+
[!INCLUDE [iot-hub-include-create-hub](../../includes/iot-hub-include-create-hub.md)]
53+
54+
### [Azure CLI](#tab/cli)
55+
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:
57+
58+
```azurecli-interactive
59+
az iot hub create --name <NEW_NAME_FOR_YOUR_IOT_HUB> --resource-group <RESOURCE_GROUP_NAME> --sku S1
60+
```
61+
62+
[!INCLUDE [iot-hub-pii-note-naming-hub](../../includes/iot-hub-pii-note-naming-hub.md)]
63+
64+
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/).
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:
69+
70+
```azurepowershell-interactive
71+
New-AzIotHub `
72+
-ResourceGroupName <RESOURCE_GROUP_NAME> `
73+
-Name <NEW_NAME_FOR_YOUR_IOT_HUB> `
74+
-SkuName S1 -Units 1 `
75+
-Location "<REGION>"
76+
```
77+
78+
[!INCLUDE [iot-hub-pii-note-naming-hub](../../includes/iot-hub-pii-note-naming-hub.md)]
79+
80+
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+
82+
---
83+
84+
## Connect to an IoT hub
85+
86+
Provide access permissions to applications and services that use IoT Hub functionality.
87+
88+
### Connect with a connection string
89+
90+
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.
91+
92+
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).
93+
94+
To get the IoT Hub connection string for the **service** policy, follow these steps:
95+
96+
#### [Azure portal](#tab/portal)
97+
98+
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.
99+
100+
1. On the left-side pane of your IoT hub, select **Shared access policies**.
101+
102+
1. From the list of policies, select the **service** policy.
103+
104+
1. Copy the **Primary connection string** and save the value.
105+
106+
#### [Azure CLI](#tab/cli)
107+
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:
109+
110+
```azurecli-interactive
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:
115+
116+
```text
117+
"HostName=<IOT_HUB_NAME>.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=<SHARED_ACCESS_KEY>"
118+
```
119+
120+
#### [Azure PowerShell](#tab/powershell)
121+
122+
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.
123+
124+
```azurepowershell-interactive
125+
Get-AzIotHubConnectionString -ResourceGroupName "<YOUR_RESOURCE_GROUP>" -Name "<YOUR_IOT_HUB_NAME>" -KeyName "service"
126+
```
127+
128+
The service connection string should look similar to the following example:
129+
130+
```text
131+
"HostName=<IOT_HUB_NAME>.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=<SHARED_ACCESS_KEY>"
132+
```
133+
134+
---
135+
136+
### Connect with role assignments
137+
138+
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).
139+
140+
## Delete an IoT hub
141+
142+
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).
143+
144+
### [Azure portal](#tab/portal)
145+
146+
To delete an IoT hub, open your IoT hub in the Azure portal, then choose **Delete**.
147+
148+
:::image type="content" source="./media/create-hub/delete-iot-hub.png" alt-text="Screenshot showing where to find the delete button for an IoT hub in the Azure portal." lightbox="./media/create-hub/delete-iot-hub.png":::
149+
150+
### [Azure CLI](#tab/cli)
151+
152+
To delete an IoT hub, run the [az iot hub delete](/cli/azure/iot/hub#az-iot-hub-delete) command:
153+
154+
```azurecli-interactive
155+
az iot hub delete --name <IOT_HUB_NAME> --resource-group <RESOURCE_GROUP_NAME>
156+
```
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+
168+
---
169+
170+
## Other tools for managing IoT hubs
171+
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:
173+
174+
* **IoT Hub resource provider REST API**
175+
176+
Use the [IoT Hub Resource](/rest/api/iothub/iot-hub-resource) set of operations.
177+
178+
* **Azure resource manager templates, Bicep, or Terraform**
179+
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).
181+
182+
* **Visual Studio Code**
183+
184+
Use the [Azure IoT Hub extension for Visual Studio Code](./reference-iot-hub-extension.md).

articles/iot-hub/device-management-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This article shows you how to create two Azure CLI sessions:
4040

4141
* Azure CLI. You can also run the commands in this article using the [Azure Cloud Shell](../cloud-shell/overview.md), an interactive CLI shell that runs in your browser or in an app such as Windows Terminal. If you use the Cloud Shell, you don't need to install anything. If you prefer to use the CLI locally, this article requires Azure CLI version 2.36 or later. Run `az --version` to find the version. To locally install or upgrade Azure CLI, see [Install Azure CLI](/cli/azure/install-azure-cli).
4242

43-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
43+
* 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).
4444

4545
* Make sure that port 8883 is open in your firewall. The device sample in this article uses MQTT protocol, which communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see [Connecting to IoT Hub (MQTT)](../iot/iot-mqtt-connect-to-iot-hub.md#connecting-to-iot-hub).
4646

articles/iot-hub/device-management-dotnet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This article shows you how to create:
2828

2929
* Visual Studio.
3030

31-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
31+
* 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).
3232

3333
* A device registered in your IoT hub. If you don't have a device in your IoT hub, follow the steps in [Register a device](create-connect-device.md#register-a-device).
3434

articles/iot-hub/device-management-java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This article shows you how to create:
2929
3030
## Prerequisites
3131

32-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
32+
* 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).
3333

3434
* A device registered in your IoT hub. If you don't have a device in your IoT hub, follow the steps in [Register a device](create-connect-device.md#register-a-device).
3535

articles/iot-hub/device-management-node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This article shows you how to create:
2626

2727
## Prerequisites
2828

29-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
29+
* 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).
3030

3131
* A device registered in your IoT hub. If you don't have a device in your IoT hub, follow the steps in [Register a device](create-connect-device.md#register-a-device).
3232

articles/iot-hub/device-management-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This article shows you how to create:
3131

3232
* An active Azure account. (If you don't have an account, you can create a [free account](https://azure.microsoft.com/pricing/free-trial/) in just a couple of minutes.)
3333

34-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
34+
* 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).
3535

3636
* A device registered in your IoT hub. If you don't have a device in your IoT hub, follow the steps in [Register a device](create-connect-device.md#register-a-device).
3737

articles/iot-hub/device-twins-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This article shows you how to create two Azure CLI sessions:
3434

3535
* Azure CLI. You can also run the commands in this article using the [Azure Cloud Shell](../cloud-shell/overview.md), an interactive CLI shell that runs in your browser or in an app such as Windows Terminal. If you use the Cloud Shell, you don't need to install anything. If you prefer to use the CLI locally, this article requires Azure CLI version 2.36 or later. Run `az --version` to find the version. To locally install or upgrade Azure CLI, see [Install Azure CLI](/cli/azure/install-azure-cli).
3636

37-
* An IoT hub. Create one with the [CLI](iot-hub-create-using-cli.md) or the [Azure portal](iot-hub-create-through-portal.md).
37+
* 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).
3838

3939
* Make sure that port 8883 is open in your firewall. The samples in this article use MQTT protocol, which communicates over port 8883. This port can be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see [Connecting to IoT Hub (MQTT)](../iot/iot-mqtt-connect-to-iot-hub.md#connecting-to-iot-hub).
4040

0 commit comments

Comments
 (0)