Create an IoT hub using the New-AzIotHub cmdlet

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.

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

Prerequisites

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 new resource group for your IoT hub, use the New-AzResourceGroup command. This example creates a resource group called MyIoTRG1 in the China East region:

New-AzResourceGroup -Name MyIoTRG1 -Location "China East"

Connect to your Azure subscription

If you're running PowerShell locally instead, enter the following command to sign in to your Azure subscription:

# Log into Azure account.
Connect-AzAccount -Environment AzureChinaCloud

Create an IoT hub

Create an IoT hub using your resource group. Use the New-AzIotHub command. This example creates an S1 hub called MyTestIoTHub in the China North region:

New-AzIotHub `
    -ResourceGroupName MyIoTRG1 `
    -Name MyTestIoTHub `
    -SkuName S1 -Units 1 `
    -Location "China East"

The name of the IoT hub must be globally unique.

Important

Because the IoT hub will be publicly discoverable as a DNS endpoint, be sure to avoid entering any sensitive or personally identifiable information when you name it.

To list all the IoT hubs in your subscription, use the Get-AzIotHub command.

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

Get-AzIotHub

To delete the IoT hub, use the Remove-AzIotHub command.

Remove-AzIotHub `
    -ResourceGroupName MyIoTRG1 `
    -Name MyTestIoTHub

Update the IoT hub

You can change the settings of an existing IoT hub after it's created. Here are some properties you can set for an IoT hub:

Pricing and scale: Migrate to a different tier or set the number of IoT Hub units.

IP Filter: Specify a range of IP addresses that will be accepted or rejected by the IoT hub.

Properties: A list of properties that you can copy and use elsewhere, such as the resource ID, resource group, location, and so on.

Explore the Set-AzIotHub commands for a complete list of update options.

Next steps

Now that you've deployed an IoT hub using a PowerShell cmdlet, explore more articles:

Develop for IoT Hub:

Explore the capabilities of IoT Hub: