Skip to content

Files

Latest commit

 

History

History
98 lines (64 loc) · 3.74 KB

iot-hub-create-using-powershell.md

File metadata and controls

98 lines (64 loc) · 3.74 KB

title: Create an Azure IoT Hub using a PowerShell cmdlet | Microsoft Docs description: How to use a PowerShell cmdlet to create an IoT hub. author: robinsh manager: timlt ms.service: iot-hub services: iot-hub ms.topic: conceptual ms.date: 08/29/2018 ms.author: robinsh

Create an IoT hub using the New-AzureRmIotHub cmdlet

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

Introduction

You can use Azure PowerShell cmdlets to create and manage Azure IoT hubs. This tutorial shows you how to create an IoT hub with PowerShell.

To complete this how-to, you need an Azure subscription. If you don't have an Azure subscription, create a free account before you begin.

[!INCLUDE cloud-shell-try-it.md]

Connect to your Azure subscription

If you are using the Cloud Shell, you are already logged in to your subscription. If you are running PowerShell locally instead, enter the following command to sign in to your Azure subscription:

# Log into Azure account.
Login-AzureRMAccount

Create a resource group

You need a resource group to deploy an IoT hub. You can use an existing resource group or create a new one.

To create a resource group for your IoT hub, use the New-AzureRmResourceGroup command. This example creates a resource group called MyIoTRG1 in the East US region:

New-AzureRmResourceGroup -Name MyIoTRG1 -Location "East US"

Create an IoT hub

To create an IoT hub in the resource group you created in the previous step, use the New-AzureRmIotHub command. This example creates an S1 hub called MyTestIoTHub in the East US region:

New-AzureRmIotHub `
    -ResourceGroupName MyIoTRG1 `
    -Name MyTestIoTHub `
    -SkuName S1 -Units 1 `
    -Location "East US"

The name of the IoT hub must be globally unique.

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

You can list all the IoT hubs in your subscription using the Get-AzureRmIotHub command:

Get-AzureRmIotHub

This example shows the S1 Standard IoT Hub you created in the previous step.

You can delete the IoT hub using the Remove-AzureRmIotHub command:

Remove-AzureRmIotHub `
    -ResourceGroupName MyIoTRG1 `
    -Name MyTestIoTHub

Alternatively, you can remove a resource group and all the resources it contains using the Remove-AzureRmResourceGroup command:

Remove-AzureRmResourceGroup -Name MyIoTRG1

Next steps

Now you have deployed an IoT hub using a PowerShell cmdlet, if you want to explore further, check out the following articles:

To learn more about developing for IoT Hub, see the following articles:

To further explore the capabilities of IoT Hub, see: