Getting Started with Microsoft Azure IoT Hub

  1. Home
  2. Microsoft Azure
  3. Getting Started with Microsoft Azure IoT Hub
Getting Started with Microsoft Azure IoT Hub

By connecting millions of devices and providing a potential revenue IoT (Internet of things) is setting the level high in the technology market. As a result, Microsoft came up with the service for turning your vision into reality using secure and scalable solutions that is Azure IoT hub. From providing a security-enhanced communication channel for sending and receiving data from IoT devices or getting compatibility with Azure IoT Edge and Azure Stack for building hybrid IoT applications, Azure IoT hub is used everywhere.

However, to learn more about this, in this blog we will be covering everything related to the Azure IoT hub including the steps to get started with it. But, before that let’s take a look at Azure IoT (Internet of things).

What is Azure IoT?

Azure Internet of Things (IoT) is a manageable platform service over edge and cloud for connecting, monitoring, and controlling billions of IoT assets. It includes security and operating systems for devices and equipment as well as data and analytics for building, deploying, and managing IoT applications in businesses. Further, the Internet of Things services work together across three components:

  • Firstly, the physical objects or things like industrial equipment, devices or sensors, that connect to the cloud persistently or intermittently.
  • Secondly, information collected by the things for analyzing and then turning into actionable knowledge either by people or AI.
  • Lastly, the way people respond to those insights and connect them to their business, as well as the systems and tools they use.
Benefits of Azure IoT

Azure IoT provides the industry’s largest portfolio of services and capabilities.

Azure iot

What is Azure IoT Hub?

Azure IoT Hub refers to a manageable service, hosted in the cloud. This behaves as a central message hub for bi-directional communication between IoT application and the devices it manages. 

Let’s check some more points to learn more about Azure IoT Hub.

  • Firstly, this is used for building IoT solutions with reliable and secure communications between millions of IoT devices and a cloud-hosted solution backend. 
  • Secondly, it supports communications both from the device to the cloud and from the cloud to the device. And, there are multiple messaging patterns in this like device-to-cloud telemetry, file upload from devices, and request-reply methods for controlling devices from the cloud. 
  • Thirdly, IoT Hub monitoring helps in maintaining the health of your solution by tracking events like 
    • device creation
    • Then, device failures
    • device connections
  • Next, it provides the ability to build scalable, full-featured IoT solutions like
    • Firstly, managing industrial equipment used in manufacturing
    • Secondly, tracking valuable assets in healthcare
    • Then, monitoring office building usage.
  • Lastly, it helps in extending your solution from the cloud to the edge with per-device authentication, built-in device management, and scaled provisioning.
Is Microsoft Azure IoT Hub worth it?

Yes! because:

  • Firstly, the Azure IoT hub provides a security-enhanced communication channel for sending and receiving data from IoT devices.
  • Secondly, the device Update for IoT Hub enables over-the-air deployment of updates for keeping IoT devices up-to-date and secure.
  • Thirdly, it involves full integration with Azure Event Grid and serverless compute for simplifying IoT application development.
  • Lastly, it has compatibility with Azure IoT Edge and Azure Stack for developing hybrid IoT applications.
Microsoft Azure IoT Hub

What are the Microsoft Azure IoT Hub features?

1. Scaling your solution
  • IoT Hub helps in scaling millions of simultaneously connected devices and events per second for supporting your IoT workloads. 
2. Securing your communications
  • IoT Hub provides a secure communication channel for your devices for sending data.
  • Secondly, per-device authentication enables each device to connect securely to IoT Hub and for each device to be managed securely.
  • Thirdly, this gives you full control over device access and connections at the per-device level.
  • Lastly, it automatically provisions devices to the right IoT hub when the device first boots up.
3. Routing device data

It provides built-in message routing functionality to get flexibility setting up automatic rules-based message fan-out:

  • Firstly, using message routing for controlling where your hub sends device telemetry.
  • Secondly, there is no additional cost for routing messages to multiple endpoints.
  • Lastly, no-code routing rules take the place of custom message dispatcher code.
4. Integrating with other services

This provides you the option to can integrate IoT Hub with other Azure services to build complete, end-to-end solutions. For example, use:

  • Firstly, Azure Event Grid for enabling your business to react quickly to critical events in a reliable, scalable, and secure manner.
  • Secondly, Azure Logic Apps for automating business processes.
  • Then, Azure Machine Learning for adding machine learning and AI models to your solution.
  • Lastly, Azure Stream Analytics for running real-time analytic computations on the data streaming from your devices.
5. Configuring and controlling your devices

Using an array of built-in functionality you can manage your devices connected to IoT Hub. For this:

  • Firstly, storing, synchronizing, and querying device metadata and state information for all your devices.
  • Secondly, setting device state either per-device or based on common characteristics of devices.
  • Lastly, automatically responding to a device-reported state change with message routing integration.
6. Connect your devices

For building applications running on your devices and interacting with IoT Hub using the Azure IoT device SDK libraries. Supported languages include:

  • C
  • Embedded C
  • C#
  • Java
  • Python
  • Node.js.

Further, there are protocols that IoT Hub and the device SDKs supports for connecting devices:

  • HTTPS
  • AMQP
  • AMQP over WebSockets
  • MQTT
  • MQTT over WebSockets
7. Establishing bidirectional communication with billions of IoT devices
  • Using device-to-cloud telemetry data for understanding the state of your devices and defining message routes to other Azure services without writing any code. However, in cloud-to-device messages, send commands and notifications to your connected devices and track message delivery with acknowledgment receipts.
8. Building and running hybrid IoT apps across datacenters
  • Azure Stack Hub refers to an extension of Azure used for providing a path for running apps in an on-premises environment and delivering Azure services in your datacenters. However, with Azure IoT Hub available on Azure Stack Hub, customers and partners will be able to build hybrid IoT apps running partially or entirely on-premises giving them the flexibility they need.
Azure Professional
What makes Azure IoT Hub secure?
  • Firstly, it decreases the risk by using Azure Defender for IoT, with security posture management and threat monitoring and remediation.
  • Secondly, increases connection security by connecting IoT devices to IoT Hub via virtual networks.
  • Lastly, it helps in protecting your business assets with our stringent security standards and the largest portfolio of compliance certifications in the industry.

Above we have learned and Azure IoT hub and features that make it unique. Now, it’s time to get started with creating an IoT hub. This section will help you get familiar with creating and managing the IoT hub.

Creating an IoT hub: Azure portal

Now, we will create an IoT hub:

1. Create an IoT hub
  • Firstly, sign in to the Azure portal.
  • Secondly, select the + Create a resource button. Then, in the search marketplace field, enter IoT Hub.
  • Thirdly, from the search results select IoT Hub and then select Create.
  • Now, complete the fields on the Basics tab:
    • Firstly, Subscription. select the subscription for use in the hub.
    • Secondly, Resource Group. Select a resource group. However, for creating a new one, select Create new and fill in the name you want to use. 
    • Thirdly, Region. Select the region for hub location.
    • Lastly, IoT Hub Name. Enter a unique name.
Create a hub in the Azure portal.
Source: Microsoft
  • After that, select Next: Networking to continue creating your hub.
    • Here, choose the endpoints for connecting to your IoT Hub. However, you can select the default setting Public endpoint or choose Public endpoint or Private endpoint.
Choose the endpoints that can connect.
Source: Microsoft
  • Then, select Next: Management for continuing in creating the hub process.
However, you can accept the default settings here. And, you can modify any of the following fields:
  1. Firstly, Pricing and scale tier: You can choose from several tiers based on how many features you want and messages you send through your solution per day. However, it gives access to 500 devices to be connected to the hub and 8,000 messages per day.
  2. Secondly, IoT Hub units. The number of messages allowed per unit per day is totally based on your hub’s pricing tier. 
  3. Thirdly, Defender for IoT. Turn this on for adding an extra layer of threat protection to IoT and your devices. 
  4. Lastly, Advanced Settings > Device-to-cloud partitions. This property links the device-to-cloud messages to the number of synchronous readers of the messages. 
  • Now, select Next: Tags to continue to the next screen.
    • Here, tags are name/value pairs. However, you can assign the same tag to multiple resources and resource groups for categorizing resources and consolidate billing.
Assign tags for the hub using the Azure portal.
Source: Microsoft
  • After that, select Next: Review + create for reviewing your choices. 
  • Lastly, select Create for creating your new hub.
2. Changing the settings of the IoT hub

After creating an IoT Hub pane, you can change the settings of an existing IoT hub.

Some of the properties you can set for an IoT hub are:

1. Pricing and scale

You can use this property for migrating to a different tier or set the number of IoT Hub units.

2. Operations monitoring

Turning the different monitoring categories on or off like logging for events related to device-to-cloud messages or cloud-to-device messages.

3. IP Filter

Defining a range of IP addresses that will either get accepted or rejected by the IoT hub.

4. Properties

Providing the list of properties for copying and using elsewhere. This includes the resource ID, resource group, location, and so on.

Shared access policies

Click on Shared access policies in the Settings section for viewing or modifying the list of shared access policies. However, these policies specify the permissions for devices and services for connecting to IoT Hub.

  • Firstly, click Add for opening the Add a shared access policy blade.
Screenshot showing adding a shared access policy
Source: Microsoft
  • Here, you can enter the new policy name and the permissions you want to associate with this policy:
    • Firstly, the Registry read and Registry write policies are for granting read and write access rights to the identity registry. 
    • Secondly, the Service connect policy is for granting permission for accessing service endpoints. This permission is used by back-end cloud services for sending and receiving messages from devices.
    • Lastly, the Device connect policy is for granting permissions for sending and receiving messages using the IoT Hub device-side endpoints. This permission is used by,
      • devices for sending and receiving messages from an IoT hub
      • updating and reading device twin
      • module twin data
      • performing file uploads.
  • Then, click Create to add this newly created policy to the existing list.
3. Registering a new device in the IoT hub
  • Firstly, open IoT Devices in your IoT hub navigation menu. Then, select New to add a device to your IoT hub.
  • Secondly, provide a name for your new device in Create a device. The name can be myDeviceId. Then, select Save for creating device identity for your IoT hub.
  • Lastly, after creating a device, open the device from the list in the IoT devices pane. Then, copy the Primary Connection String for using it later.
4. Message Routing for an IoT hub

Firstly, click Message Routing under Messaging for viewing the Message Routing pane. Then, specify the routes and custom endpoints for the hub. 

However, message routing is for managing how data is sent from your devices to your endpoints. The initial step here is to add a new route. After that, you can add an existing endpoint to the route. Or further, create a new one of the types supported, like blob storage.

Routes

  • On the Message Routing pane, Routes is the first tab. For adding a new route, click +Add.
Screenshot showing adding a new route
Source: Microsoft
  • Then, Name your route. The route name must be unique.
  • After that, Endpoint. For this, you can select one from the dropdown list, or add a new one. For example, a storage account and container are already available. Further, for adding them as an endpoint, click +Add next to the Endpoint dropdown and select Blob Storage. 
  • Now, click Pick a container for selecting the storage account and container. After selecting those fields, it returns to the Endpoint pane. Using the defaults for the rest of the fields and Create for creating the endpoint for the storage account. Then, add it to the routing rules.
  • Next, for Data source, select Device Telemetry Messages.
  • Then, add a routing query. In this example, the messages contain an application property called level with a value equal to critical are routed to the storage account.
  • Lastly, click Save for saving the routing rule. Now, you will get back to the Message Routing pane, and a new routing rule is displayed.

Custom endpoints

For this, click the Custom endpoints tab. There you will see any custom endpoints already created. From here, you can add new endpoints or delete existing endpoints.

However, you can define up to 10 custom endpoints for an IoT hub.

5. Find a specific IoT hub

For finding a specific IoT hub in your subscription, the ways are:

  • Firstly, if you know the resource group to which the IoT hub belongs, just click Resource groups.
    • Then select the resource group from the list. 
    • After that, the resource group screen displays all of the resources in that group, including the IoT hubs. 
    • Now, click on the hub for which you’re looking.
  • Secondly, click All resources. There is a dropdown list that defaults to All types on the All resources pane. 
    • Then, click on the dropdown list, uncheck Select all. 
    • Next, Find IoT Hub and check it. 
    • Lastly, click on the dropdown list box for closing it, and the entries will be filtered, showing only your IoT hubs.
6. Deleting the IoT hub

For deleting an IoT hub, find the IoT hub you want to delete. After that, click the Delete button mentioned below the IoT hub name.

Azure IoT Hub pricing

Azure IoT helps in connecting, monitoring, and controlling billions of IoT assets without the need for any upfront cost or termination fees. In Azure IoT hub pricing, you pay only for what you need. The pricing options include:

Basic tier

Edition TypePrice per IoT Hub unit (per month)Total number of messages/day per IoT Hub unitMessage meter size
B1₹720.4534,00,0004 KB
B2₹3,602.26360,00,0004 KB
B3₹36,022.6330,00,00,0004 KB
Source: Microsoft

Standard tier

Edition TypePrice per IoT Hub unit (per month)Total number of messages/day per IoT Hub unitMessage meter size
FreeFree8,0000.5 KB
S1₹1,801.1324,00,0004 KB
S2₹18,011.31560,00,0004 KB
S3₹1,80,113.1530,00,00,0004 KB
Source: Microsoft

Azure IoT Hub Device Provisioning Service

The Azure IoT Hub Device Provisioning Service is for enabling zero-touch provisioning to the right IoT Hub without requiring human intervention. This allows customers for provisioning millions of devices in a secure and scalable manner. Moreover, it enables device lifecycle support and important capabilities together with IoT Hub device management. This further helps customers address all stages of IoT device lifecycle.

TierPrice
S1 General Availability Price: ₹8.862 per 1,000 operations
Source: Microsoft

Final Words

Above we learned about the Azure IoT hub services for connecting, monitoring, and controlling millions of IoT assets running on a broad set of operating systems. This provides security for your IoT solutions by using per-device authentication for communicating with devices with the appropriate credentials. Moreover, many top companies like Maersk, Ecolab, and Mexa have shown their trust in the Azure IoT hub. So at last, go through the article for getting familiar with the internet of things services. Use the documentation for getting started it. I hope the above information will help you in starting your journey in the world of the Internet of things (IoT).

Iot developer
Menu