Book Image

Azure IoT Development Cookbook

By : Yatish Patil
Book Image

Azure IoT Development Cookbook

By: Yatish Patil

Overview of this book

Microsoft’s end-to-end IoT platform is the most complete IoT offering, empowering enterprises to build and realize value from IoT solutions efficiently. It is important to develop robust and reliable solutions for your organization to leverage IoT services. This book focuses on how to start building custom solutions using the IoT hub or the preconfigured solution of Azure IoT suite. As a developer, you will be taught how to connect multiple devices to the Azure IoT hub, develop, manage the IoT hub service and integrate the hub with cloud. We will be covering REST APIs along with HTTP, MQTT and AMQP protocols. It also helps you learn Pre-Configured IoT Suite solution. Moving ahead we will be covering topics like:-Process device-to-cloud messages and cloud-to-device messages using .Net-Direct methods and device management-Query Language, Azure IoT SDK for .Net-Creating and managing, Securing IoT hub, IoT Suite and many more. We will be using windows 10 IoT core, Visual Studio, universal Windows platform. At the end, we will take you through IoT analytics and provide a demo of connecting real device with Azure IoT.
Table of Contents (10 chapters)

Creating Azure IoT Hub from PowerShell

How to do it...

Let's look at this section to create IoT Hub using PowerShell:

  1. Open PowerShell in administrator mode:
Start PowerShell in administrator mode
  1. Once the PowerShell window is ready, log in to the Azure account using the command:
'Login-AzureRmAccount'
Login to Azure account
  1. If you have only one Azure subscription, then you are good to go.
  2. If you have multiple subscriptions, first we need to select the subscription which we need to work on.
  3. To view a list of all the available Azure subscription for your work use the following command:
'Get-AzureRMSubscription'
  1. 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
  1. Before we create the IoT Hub, we need to create a resource group, which this IoT Hub will be a part of.
  2. The command to create a new resource group is the following:
New-AzureRmResourceGroup -Name MyBookIoTHub -Location "West US"
Add new resource group
  1. 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
  1. You can log in to the Azure portal and view the newly created IoT Hub:
IoT Hub list view
  1. To view the available IoT Hub in your account, use the command:
Get-AzureRmIotHub
  1. To delete an existing IoT Hub, use the following command:
Remove-AzureRmIotHub `
-ResourceGroupName MyBookIoTHub `
-Name MyBookIoTHub