|
1 | 1 | ---
|
2 |
| -title: Create an IoT Hub using Azure CLI (az.py) | Microsoft Docs |
3 |
| -description: How to create an Azure IoT hub using the cross-platform Azure CLI 2.0 (az.py). |
4 |
| -author: dominicbetts |
5 |
| -manager: timlt |
| 2 | +title: Create an IoT Hub using Azure CLI | Microsoft Docs |
| 3 | +description: How to create an Azure IoT hub using Azure CLI. |
| 4 | +author: robinsh |
6 | 5 | ms.service: iot-hub
|
7 | 6 | services: iot-hub
|
8 | 7 | ms.topic: conceptual
|
9 |
| -ms.date: 06/16/2017 |
10 |
| -ms.author: dobett |
| 8 | +ms.date: 08/23/2018 |
| 9 | +ms.author: robinsh |
11 | 10 | ---
|
12 | 11 |
|
13 |
| -# Create an IoT hub using the Azure CLI 2.0 |
| 12 | +# Create an IoT hub using Azure CLI |
14 | 13 |
|
15 | 14 | [!INCLUDE [iot-hub-resource-manager-selector](../../includes/iot-hub-resource-manager-selector.md)]
|
16 | 15 |
|
17 |
| -## Introduction |
| 16 | +This article shows you how to create an IoT hub using Azure CLI. |
18 | 17 |
|
19 |
| -You can use Azure CLI 2.0 (az.py) to create and manage Azure IoT hubs programmatically. This article shows you how to use the Azure CLI 2.0 (az.py) to create an IoT hub. |
| 18 | +## Prerequisites |
20 | 19 |
|
21 |
| -You can complete the task using one of the following CLI versions: |
| 20 | +To complete this how-to, you need an Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
22 | 21 |
|
23 |
| -* [Azure CLI (azure.js)](iot-hub-create-using-cli-nodejs.md) – the CLI for the classic and resource management deployment models. |
24 |
| -* Azure CLI 2.0 (az.py) - the next generation CLI for the resource management deployment model as described in this article. |
25 |
| - |
26 |
| -To complete this tutorial, you need the following: |
27 |
| - |
28 |
| -* An active Azure account. If you don't have an account, you can create a [free account][lnk-free-trial] in just a couple of minutes. |
29 |
| -* [Azure CLI 2.0][lnk-CLI-install]. |
| 22 | +[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)] |
30 | 23 |
|
31 | 24 | ## Sign in and set your Azure account
|
32 | 25 |
|
33 |
| -Sign in to your Azure account and select your subscription. |
34 |
| - |
35 |
| -1. At the command prompt, run the [login command][lnk-login-command]: |
36 |
| - |
37 |
| - ```azurecli |
38 |
| - az login |
39 |
| - ``` |
| 26 | +If you are running Azure CLI locally instead of using Cloud Shell, you need to sign in to your Azure account. |
40 | 27 |
|
41 |
| - Follow the instructions to authenticate using the code and sign in to your Azure account through a web browser. |
| 28 | +At the command prompt, run the [login command](https://docs.microsoft.com/cli/azure/get-started-with-azure-cli): |
42 | 29 |
|
43 |
| -2. If you have multiple Azure subscriptions, signing in to Azure grants you access to all the Azure accounts associated with your credentials. Use the following [command to list the Azure accounts][lnk-az-account-command] available for you to use: |
44 |
| - |
45 | 30 | ```azurecli
|
46 |
| - az account list |
| 31 | + az login |
47 | 32 | ```
|
48 | 33 |
|
49 |
| - Use the following command to select subscription that you want to use to run the commands to create your IoT hub. You can use either the subscription name or ID from the output of the previous command: |
50 |
| -
|
51 |
| - ```azurecli |
52 |
| - az account set --subscription {your subscription name or id} |
53 |
| - ``` |
| 34 | +Follow the instructions to authenticate using the code and sign in to your Azure account through a web browser. |
54 | 35 |
|
55 | 36 | ## Create an IoT Hub
|
56 | 37 |
|
57 | 38 | Use the Azure CLI to create a resource group and then add an IoT hub.
|
58 | 39 |
|
59 |
| -1. When you create an IoT hub, you must create it in a resource group. Either use an existing resource group, or run the following [command to create a resource group][lnk-az-resource-command]: |
| 40 | +1. When you create an IoT hub, you must create it in a resource group. Either use an existing resource group, or run the following [command to create a resource group](https://docs.microsoft.com/cli/azure/resource): |
60 | 41 |
|
61 |
| - ```azurecli |
62 |
| - az group create --name {your resource group name} --location westus |
63 |
| - ``` |
64 |
| -
|
65 |
| - > [!TIP] |
66 |
| - > The previous example creates the resource group in the West US location. You can view a list of available locations by running the command `az account list-locations -o table`. |
67 |
| - > |
68 |
| - > |
69 |
| -
|
70 |
| -2. Run the following [command to create an IoT hub][lnk-az-iot-command] in your resource group, using a globally unique name for your IoT hub: |
| 42 | + ```azurecli |
| 43 | + az group create --name {your resource group name} --location westus |
| 44 | + ``` |
| 45 | + |
| 46 | + > [!TIP] |
| 47 | + > The previous example creates the resource group in the West US location. You can view a list of available locations by running this command: |
| 48 | + > |
| 49 | + >``` bash |
| 50 | + >az account list-locations -o table |
| 51 | + >``` |
| 52 | + > |
| 53 | +
|
| 54 | +2. Run the following [command to create an IoT hub](https://docs.microsoft.com/cli/azure/iot/hub#az-iot-hub-create) in your resource group, using a globally unique name for your IoT hub: |
71 | 55 |
|
72 |
| - ```azurecli |
73 |
| - az iot hub create --name {your iot hub name} --resource-group {your resource group name} --sku S1 |
74 |
| - ``` |
| 56 | + ```azurecli |
| 57 | + az iot hub create --name {your iot hub name} \ |
| 58 | + --resource-group {your resource group name} --sku S1 |
| 59 | + ``` |
75 | 60 |
|
76 | 61 | [!INCLUDE [iot-hub-pii-note-naming-hub](../../includes/iot-hub-pii-note-naming-hub.md)]
|
77 | 62 |
|
78 | 63 |
|
79 |
| -> [!NOTE] |
80 |
| -> The previous command creates an IoT hub in the S1 pricing tier for which you are billed. For more information, see [Azure IoT Hub pricing][lnk-iot-pricing]. |
81 |
| -> |
| 64 | +The previous command creates an IoT hub in the S1 pricing tier for which you are billed. For more information, see [Azure IoT Hub pricing](https://azure.microsoft.com/pricing/details/iot-hub/). |
82 | 65 |
|
83 | 66 | ## Remove an IoT Hub
|
84 | 67 |
|
85 |
| -You can use the Azure CLI to [delete an individual resource][lnk-az-resource-command], such as an IoT hub, or delete a resource group and all its resources, including any IoT hubs. |
| 68 | +You can use Azure CLI to [delete an individual resource](https://docs.microsoft.com/cli/azure/resource), such as an IoT hub, or delete a resource group and all its resources, including any IoT hubs. |
86 | 69 |
|
87 |
| -To delete an IoT hub, run the following command: |
| 70 | +To [delete an IoT hub](https://docs.microsoft.com/cli/azure/iot/hub#az-iot-hub-delete), run the following command: |
88 | 71 |
|
89 | 72 | ```azurecli
|
90 |
| -az iot hub delete --name {your iot hub name} --resource-group {your resource group name} |
| 73 | +az iot hub delete --name {your iot hub name} -\ |
| 74 | + -resource-group {your resource group name} |
91 | 75 | ```
|
92 | 76 |
|
93 |
| -To delete a resource group and all its resources, run the following command: |
| 77 | +To [delete a resource group](https://docs.microsoft.com/cli/azure/group#az-group-delete) and all its resources, run the following command: |
94 | 78 |
|
95 | 79 | ```azurecli
|
96 | 80 | az group delete --name {your resource group name}
|
97 | 81 | ```
|
98 | 82 |
|
99 | 83 | ## Next steps
|
100 |
| -To learn more about developing for IoT Hub, see the following articles: |
101 |
| - |
102 |
| -* [IoT Hub developer guide][lnk-devguide] |
103 |
| - |
104 |
| -To further explore the capabilities of IoT Hub, see: |
105 |
| - |
106 |
| -* [Using the Azure portal to manage IoT Hub][lnk-portal] |
107 |
| - |
108 |
| -<!-- Links --> |
109 |
| -[lnk-free-trial]: https://azure.microsoft.com/pricing/free-trial/ |
110 |
| -[lnk-CLI-install]: https://docs.microsoft.com/cli/azure/install-az-cli2 |
111 |
| -[lnk-login-command]: https://docs.microsoft.com/cli/azure/get-started-with-az-cli2 |
112 |
| -[lnk-az-account-command]: https://docs.microsoft.com/cli/azure/account |
113 |
| -[lnk-az-register-command]: https://docs.microsoft.com/cli/azure/provider |
114 |
| -[lnk-az-addcomponent-command]: https://docs.microsoft.com/cli/azure/component |
115 |
| -[lnk-az-resource-command]: https://docs.microsoft.com/cli/azure/resource |
116 |
| -[lnk-az-iot-command]: https://docs.microsoft.com/cli/azure/iot |
117 |
| -[lnk-iot-pricing]: https://azure.microsoft.com/pricing/details/iot-hub/ |
118 |
| -[lnk-devguide]: iot-hub-devguide.md |
119 |
| -[lnk-portal]: iot-hub-create-through-portal.md |
| 84 | + |
| 85 | +To learn more about using an IoT hub, see the following articles: |
| 86 | + |
| 87 | +* [IoT Hub developer guide](iot-hub-devguide.md) |
| 88 | +* [Using the Azure portal to manage IoT Hub](iot-hub-create-through-portal.md) |
0 commit comments