Azure IoT Hub is a fully managed service that enables reliable and secure bi-directional communications between millions of IoT devices and an application back end. You can learn more about Azure IoT Hub visiting the documentation site.
Before you can communicate with IoT Hub from a device you must create an IoT hub instance in your Azure subscription and then provision your device in your IoT hub.
Because of developers preferences and constrains, there are several ways you can create an instance of Azure IoT Hub service and manage this instance. Below are links to resources that will walk you through the steps required to setup an IoT hub and manage it.
- ... using the Azure portal
- ... using the Azure CLI 2.0 - Python command line
- ... using the Azure CLI 1.0 - Node.js command line
- ... using PowerShell and a resource manager template
- ... using C# and a resource manager template
- ... using C# and the resource provider REST APIs
Once you have an Azure IoT hub instance deployed, you will need to manage and interact with it to perform the following operations:
- Work with the device registry (Create, Update, Delete device IDs)
- Retrieve device credentials
- Retrieve user credentials
- Send Cloud to Device messages to devices
- Work with Device Twins
- Invoke Device Direct Methods
- Monitor operations of the service
There is some of this interaction that can happen through the Azure portal, but most of the interaction will happen through tools and leveraging the various service client SDKs.
The first thing you will need to do before you can use a tool or start developing an application that will interact with the IoT hub using one of the service client SDKs is to retrieve user credentials.
It is important to understand the difference between user credentials and device credentials:
- The device credentials are managed by the IoT Hub identity registry and are to be used by code on devices
- The user credentials are set at the IoT Hub settings level and allow to define user access policies for applications that will manage the IoT hub. Details on Control access to IoT Hub can be found here.
You will need to get user credentials with the right permissions to interact with the identity registry, to send C2D messages, and to work with the Device Twins and Methods. The user credentials can easily be found on the Azure portal in the "Shared Access Policies" section of the IoT hub settings blade. Now you have the credentials, you can create
- ... using iothub-explorer (node.js command line tool)
- ... using Device Explorer (Windows desktop application)
- ... using the service client SDK ...
- ... for C#
- ... for Node.js
- ... for java
- ... for Python
- ... using Azure CLI v2.0 (Python command line tool)
There is a way to monitor an Azure IoT hub operations as all of these are logged into an Event Hub. This can help debug applications developed to interact and manage an IoT hub. Everything you need to know about IoT Hub operations monitoring is here.
Once you have a device ID, you can provision your device with it and start interacting with it from the Cloud through IoT Hub.
When developing, you can leverage some tools that will make your life easier. The below will allow you to do pretty much everything you need to do when developing and testing IoT devices connecting to Azure IoT:
- iothub-explorer (node.js command line tool)
- Device Explorer (Windows desktop application)
To build applications to manage the IoT hub and interact with devices from the Cloud, you can leverage one of our service client SDKs: