Creating an IoT Hub in Microsoft Azure

Introduction

IoT Hub is a service provided by Microsoft Azure that can be used to connect, provision and manage millions of IoT devices; communicating large amounts of data per month.

IoT Hub acts as a bridge between devices and their solutions in the cloud, allowing them to store, analyze and act on data in real time.

It enables secure and reliable bi-directional communication (from Device to Cloud [D2C] and from Cloud to Device [C2D]) over widely used IoT communication protocols such as HTTP, MQTT and AMQPS.

You can refer the IoT Hub Documentation by Microsoft Azure for more information.

 

Creating an IoT Hub

You can create an IoT Hub by following the steps given below :

1.  Sign in to your Microsoft Azure account.

2.  Select New --> Internet of Things --> IoT Hub

Add IoT Hub

3.  After you click on IoT Hub, an IoT Hub pane (window) will open. Fill in the basic information asked in this pane.

  • Name : Select a name for your IoT Hub. If the name is valid, a green check mark will appear.
    Note: The IoT Hub is publically discoverable as a DNS endpoint, so avoid sensitive information while naming it.
  • Pricing and Scale Tier : Select appropriate option according to the need of your application and based on your budget. The prices and capacities are shown in a new pane once you click on this option.
    Here, we have chosen the F1-Free Tier IoT Hub.
    Note : Only 1 F1-Free Tier IoT Hub is available per account. So don’t delete the free IoT Hub once you have created it. You won’t be able to select an F1-Free Tier IoT Hub again.
  • Resource Group : Create a resource group to host the IoT Hub. You can also use an existing resource group if you had created one earlier.
  • Location : Select the location closest to you.
    You need to scroll down to see this option in the pane.
    We have selected Central India.
  • You can choose to pin this IoT Hub to the dashboard by checking the Pin to dashboard option.
  • Click on Create to create the IoT Hub. It may take a few minutes to create the IoT Hub.
    You will get a notification on completion of creation of the IoT Hub.

 

IoT Hub Details

Important information required for connecting devices and applications to the IoT Hub can be found by clicking on the IoT Hub name from the All resources (or by clicking on the IoT Hub name on the dashboard if it is pinned to the dashboard).


Click on the name of the IoT Hub you created. A new window will open. Note down the Hostname from this window as shown in the image below. After noting the Hostname, click on the Shared access policies in the Settings. The Shared access policies is highlighted in the image below. 

Shared Access Policies

 

In the Shared access policies pane, click on the iothubowner option under Policy. Note down the Primary key and the Connection string-primary key of your IoT Hub. You will require these strings at a later stage while developing applications. You can copy these strings and note them down in some file, or you can access them later in the manner explained above.
This is shown in the image below. 

IoT Hub Strings

 

Use the Save option if you make any changes to the Permissions (Registry Read/Write and Service/Device Connect).

 

Registering a Device in the IoT Hub for your Device

Follow the steps given below to register a device in your IoT Hub :

1.  Open your IoT Hub and click on Device Explorer(name changed to IoT Devices in the latest UI of Azure).

2.  In the Device Explorer pane, click on Add to add a device to the hub.

3.  In the Add Device pane that opens, fill in the following information :  

  • Device ID : Enter Id for the device. Device Ids need to be unique. A green check mark will appear if it is a valid device Id. Device Ids are case sensitive.
    Note : The device ID may be visible in the logs collected for customer support and troubleshooting, so make sure to avoid sensitive information while naming the device.
  • Authentication Type : Select Symmetric Key.
  • Auto Generate Keys : Select this check box.
  • Connect Device to IoT Hub : Click Enable.

4.   Click on Save.

5.   Once the device is created, it will be listed in the Device Explorer option from where we added the device. Click on the name of the device. This will open the Device Details pane.

6.   Note down the Primary key and the Connection string-primary key of the Device. You will require these strings at a later stage while developing applications. You can copy these strings and note them down in some file, or you can access them later in the manner explained above.
This is shown in the image below.

IoT Hub Device Details

 


Ad