Skip to content

Files

Latest commit

7e303ca · Mar 18, 2022

History

History
74 lines (50 loc) · 2.73 KB

iot-hub-create-using-cli.md

File metadata and controls

74 lines (50 loc) · 2.73 KB
title description author ms.service services ms.topic ms.date ms.author
Create an IoT Hub using Azure CLI | Microsoft Docs
Learn how to use the Azure CLI commands to create a resource group and then create an IoT hub in the resource group. Also learn how to remove the hub.
kgremban
iot-hub
iot-hub
conceptual
08/23/2018
kgremban

Create an IoT hub using the Azure CLI

[!INCLUDE iot-hub-resource-manager-selector]

This article shows you how to create an IoT hub using Azure CLI.

[!INCLUDE quickstarts-free-trial-note]

[!INCLUDE azure-cli-prepare-your-environment.md]

Create an IoT Hub

Use the Azure CLI to create a resource group and then add an IoT hub.

  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:

    az group create --name {your resource group name} --location westus
    

    [!TIP] The previous example creates the resource group in the West US location. You can view a list of available locations by running this command:

    az account list-locations -o table
    
  2. Run the following command to create an IoT hub in your resource group, using a globally unique name for your IoT hub:

    az iot hub create --name {your iot hub name} \
       --resource-group {your resource group name} --sku S1
    

    [!INCLUDE iot-hub-pii-note-naming-hub]

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.

Remove an IoT Hub

You can use Azure CLI to delete an individual resource, such as an IoT hub, or delete a resource group and all its resources, including any IoT hubs.

To delete an IoT hub, run the following command:

az iot hub delete --name {your iot hub name} -\
  -resource-group {your resource group name}

To delete a resource group and all its resources, run the following command:

az group delete --name {your resource group name}

Next steps

To learn more about using an IoT hub, see the following articles: