Azure IoT Hub
- A cloud-hosted solution back end (Platform-as-a-service, PaaS) to connect Securely and Reliably to any device in field. Provides Per-device authentication, Device Management, Scaled Provisioning.
- Available as an on-premises solution using Azure Stack Hub.
IoT Hub Variations
- Two tiers/packages of IoT Hub:
- Basic Tier
- provides a subset of features and is intended for solutions that only need uni-directional communication from devices to the cloud.
- Standard Tier
- To develop full-featured and bi-directional communication capabilities
- device-to-cloud telemetry
- Per-device identity
- Message routing
- message enrichments
- Event Grid integration
- support for HTTP, AMQP, and MQTT protocol
- Device Provisioning Service
- Monitoring and diagnostics
- Cloud-to-device messaging
- Device twins
- Module twins
- Device management
- Device streams
- Azure IoT Edge
- IoT Plug and Play Preview
- Basic Tier
- Both tiers offer same kind of security and authentication.
- IoT Hub is available in 3 sizes, to choose from depending upon the Data Throughput you are considering. Each unit of a level 1 IoT hub can handle 400 thousand messages a day, while a level 3 unit can handle 300 million.
Protocol support
- IoT Hub supports following protocols for device connection:
- MQTT
- MQTT over WebSocket
- HTTPS 1.1
- AMQP
- AMQP over WebSocket
Device Identity Registry:
- Stores information about the devices and modules permitted to connect to the IoT Hub.
- Devices needs to authenticate with the credentials stored in the registry.
Authentication:
- Grants access to endpoints by verifying a token against the shared access policies and identity registry security credentials.
- Supported certificates:
- An existing X.509 certificate
- CA-signed X.509 certificate
- A self-generated and self-signed X-509 certificate
Device Twin:
- JSON documents that store device state information, including metadata, configurations, and conditions.
- Maintains a device twin for each device that you connect to IoT Hub.
IoT Hub Endpoints:
- Send device-to-cloud messages
- Receive cloud-to-device messages
- Initiate file uploads
- Retrieve and update device twin properties
- Receive direct method requests
- Additional (custom) endpoints for Azure services:
- Azure Storage containers
- Event Hubs
- Service Bus Queues
- Service Bus Topics
Device Provisioning Service:
- Enables zero-touch, just-in-time provisioning to the right IoT Hub (~regional) without requiring human intervention, allowing the customers to provision millions of devices in a secure and scalable manner.
Telemetry Function:
- The telemetry function involves recording and transmitting values received by an IoT device.
Direct Method invocation from IoT Hub:
- Represent a request-reply interaction with a device.
- This approach is useful for scenarios where the course of immediate action is different depending on whether the device was able to respond.
- Each device method targets a single device.
- Schedule jobs on multiple devices shows how to provide a way to invoke direct methods on multiple devices, and schedule method invocation for disconnected devices.
- May have zero or more inputs/parameters in the method payload. (max. payload size = 128KB)
- Invoked through a service-facing URI:
{iot hub}/twins/{device id}/methods/
. - Device receives direct methods through a device-specific MQTT topic:
$iothub/methods/POST/{method name}/
or through AMQP links. - Direct methods are synchronous and either succeed or fail after the timeout period (default: 30 seconds, settable between 5 and 300 seconds)
- There is no guarantee on ordering or any concurrency semantics on method calls.
- further details
Schedule Jobs on IoT devices
- Jobs execute device twin updates and direct methods against a set of devices at a scheduled time.
- Consider using jobs when you need to schedule and track progress any of the following activities on a set of devices:
- Update desired properties
- Update tags
- Invoke direct methods
- Job Properties
- jobId
- startTime, endTime
- type:
- scheduleUpdateTwin: A job used to update a set of desired properties or tags.,
- scheduleDeviceMethod: A job used to invoke a device method on a set of device twins.
- status:
- pending, scheduled, running, cancelled, failed, completed
- deviceJobStatistics:
- deviceCount
- failedCount
- succeededCount
- runningCount
- pendingCount
Cloud-to-device communication ways
- Direct methods
- Used for communications that require immediate confirmation of the result.
- Direct methods are often used for interactive control of devices such as turning on a fan.
- Twin’s desired properties
- Used for long-running commands intended to put the device into a certain desired state.
- For example, set the telemetry send interval to 30 minutes.
- Cloud-to-device messages
- Used for one-way notifications to the device app.
- Further detailed comparison of the various cloud-to-device communication options
Azure IoT Hub on Premise:
Lambda/Serverless Architecture few points to note:
- The Lambda architecture of Azure IoT enables multiple paths for data storage and processing.
- Possible issues with Lambda architecture:
- Duplication of data and code.
- Greater chance of an unwanted divergence between the duplicate copies.
- There may be code duplication in the analysis apps, if there are separate apps for the hot and cold paths.
- Costs:
- Fast services tend to be the more expensive, slower services cheaper.
- There’s usually a compromise to be made.