All Articles

How To Provision IoT Hub and a Device

What is IoT

Fist lets understand what is IoT, IoT is stand for Internet of Things that is a network of Internet connected devices that communicate embedded sensor data to the cloud for centralized processing. We can divide IoT solution into two main part that we will discuss later.

  1. Device side that acts as data source i.e sensors.
  2. Cloud side that collects that data and process it furthur to analyzing data.

Azure IoT Hub

IoT Hub is a microsoft azure managed service hosted on cloud that acts as a cloud gateway for communication between an IoT application and its attached devices. It provides bi-directional message communication like device to cloud and cloud to device. You can connect millions of devices and their backend solutions reliably and securely. Almost any device can be connected to an IoT hub.

Below is Azure IoT solution architecture flow diagram.

iotarchitecture.png

Things: The physical devices such as industrial equipment, devices, and sensors, that connect to the cloud.
Insights: The data collected by the things that’s analyzed and generate the meaningful data either by people or AI.
Actions: Take Action to improve business by data generated by Insights.

There are lots of topics in Azure IoT Hub to discuss but we can not cover all in one article, so we will cover all in upcoming articles.

IoTHub has following message communications methods, we will do hands-on each in upcoming articles

  • Send device-to-cloud messages.
  • Receive cloud-to-device messages.
  • File uploads.
  • Retrieve and update device twin properties.
  • Direct method.

Let’s start with provisioning a IoT Hub and a device

Prerequisite
You must have an Azure subscription, if not, you can get a credit of $200 for one month free by clicking here.

Step 1. Asuming you have logged in into azure portal. Click on All services-> Internet of Things-> IoT Hub.

iothubpro-1.png

Step 2. Click on Create button on top left or Create IoT Hub on middle.

iothubpro-2.png

Step 3. You can provide the inputs accordingly, as I have provided the following:

Subscription: It will be auto-populated and if you have multiple subscriptions then you can select whichever you want, if you have free trial then select that.

Resource Group: If you have already created it earlier then you can use that one, otherwise click on Create Now and create it, because to create any azure service, we require resource group, it’s like a container.

IoT Hub Name: You can give your IoT Hub name as I have given the azjuntiontot.

Region: Select the region the closest one to you. I have selected East US because sometimes a free subscription doesn’t have service available to a nearby location.

Tier: I have selected the free tier as we do not need to send message more than 8000 per day, so it’s good to use this one for learning.

Now you do not go to networking and other further configuration, keep it as is and click on review and create button.

iothubpro-3.png

Step 4. It will take a couple of minutes to deploy IoT Hub and you will see Go To Resource button after deployment of Iot Hub.

iothubpro-4.png

Step 5. After clicking on Go To Resource button, you will navigate to IoT Hub overview check the details then click on Devices on left side bar and click on Add Device to add a device to IoT Hub.

iothubpro-5.png

Step 6. You need to provide following details:-

Device Id: Provide a name for your new device as I have provided azjunction-device, and Save. This action creates a device identity for your IoT hub.

Authentication type: IoT Hub provides three authentication methods for communication between the device and the hub. Shared Access Signature (SAS) token-based authentication or X.509 Self Signed certificate-based authentication or X.509 CA(certificate authorit) certificate-based authentication.

Leave Auto-generate keys checked so that the primary and secondary keys will be generated automatically.

iothubpro-6.png

Step 7. Here is your brand new device created, you can click it on and check the key details.

iothubpro-7.png

In the next article, we will send telemetry message from device to cloud.

Published Jan 1, 2023

.Net Azure Developer, a proud father.