
上QQ阅读APP看书,第一时间看更新
How to do it...
Let's look at this section to create IoT Hub using PowerShell:
- Open PowerShell in administrator mode:

Start PowerShell in administrator mode
- Once the PowerShell window is ready, log in to the Azure account using the command:
'Login-AzureRmAccount'

Login to Azure account
- If you have only one Azure subscription, then you are good to go.
- If you have multiple subscriptions, first we need to select the subscription which we need to work on.
- To view a list of all the available Azure subscription for your work use the following command:
'Get-AzureRMSubscription'
- Select the subscription with the command, (in my case it is Visual Studio Enterprise):
Select-AzureRMSubscription -SubscriptionName "{subscription name}"

Select the Azure account to work with
- Before we create the IoT Hub, we need to create a resource group, which this IoT Hub will be a part of.
- The command to create a new resource group is the following:
New-AzureRmResourceGroup -Name MyBookIoTHub -Location "West US"

Add new resource group
- We will create the IoT Hub using the following command:
New-AzureRmIotHub `
-ResourceGroupName MyBookIoTHub `
-Name MyBookIoTHub `
-SkuName S1 -Units 1 `
-Location "West US"

Azure IoT Hub created
- You can log in to the Azure portal and view the newly created IoT Hub:

IoT Hub list view
- To view the available IoT Hub in your account, use the command:
Get-AzureRmIotHub
- To delete an existing IoT Hub, use the following command:
Remove-AzureRmIotHub `
-ResourceGroupName MyBookIoTHub `
-Name MyBookIoTHub