Skip to main content
Version: 2.3.1

Azure IoT Hub Azure IoT Hub Integration Guide

Connect MaestroHub to Azure IoT Hub for device-to-cloud (D2C) telemetry, cloud-to-device (C2D) messaging, and Device Twin property management. This guide covers connection setup, function configuration, and pipeline integration.

Overview

The Azure IoT Hub connector provides:

  • Device-to-Cloud (D2C) telemetry with message routing properties and configurable QoS
  • Cloud-to-Device (C2D) message reception for receiving commands from the cloud
  • Device Twin reported property updates to push device state to Azure IoT Hub
  • Device Twin desired property subscriptions to react to cloud-side configuration changes
  • Three authentication methods: SAS device key, shared access policy, and X.509 certificate
  • Store & Forward resilience to buffer D2C messages during network outages and retry when connectivity is restored
  • Automatic SAS token renewal at 75% of the configured TTL for uninterrupted connectivity
Companion Protocols

Combine Azure IoT Hub D2C writes with OPC UA reads, Modbus polling, or MQTT triggers to bridge shop-floor data into the Azure cloud IoT platform.

Connection Configuration

Creating an Azure IoT Hub Connection

Navigate to Connections -> New Connection -> Azure IoT Hub and configure the fields below.

Azure IoT Hub Connection Creation Fields

1. Profile Information
FieldDefaultDescription
Profile Name-A descriptive name for this connection profile (required, max 100 characters)
Description-Optional description for this Azure IoT Hub connection
2. Connection Settings
FieldDefaultDescription
IoT Hub Hostname-Azure IoT Hub hostname (e.g., myhub.azure-devices.net) - required, minimum 5 characters
Device ID-Device identity registered in Azure IoT Hub (required, max 128 characters)
3. Authentication
FieldDefaultDescription
Authentication MethodSAS KeyAuthentication method to use: SAS Key, Shared Access Policy, or X.509 Certificate

The connector supports three authentication methods. The required fields change based on the selected method:

SAS Key (Device Symmetric Key)

FieldDefaultDescription
Device Key-Base64-encoded device symmetric key from the Azure IoT Hub device identity (required). Stored securely and masked on edit.

Shared Access Policy

FieldDefaultDescription
Policy Name-Shared access policy name (e.g., iothubowner, device) - required
Policy Key-Base64-encoded policy key (required). Stored securely and masked on edit.

X.509 Certificate

FieldDefaultDescription
Client Certificate (PEM)-PEM-encoded X.509 device certificate. The certificate CN must match the Device ID (required). Stored securely and masked on edit.
Client Private Key (PEM)-PEM-encoded private key for the device certificate (required). Stored securely and masked on edit.
Security Notice

Credentials are encrypted and stored securely. They are never logged or displayed in plain text. When editing an existing connection, leave credential fields empty to keep the stored values, or enter new values to update them.

Recommended Authentication

For production deployments, X.509 certificate authentication provides the strongest security. SAS Key is the simplest to set up for testing and development. Shared Access Policy is useful when multiple devices share a policy.

4. Advanced Settings
FieldDefaultDescription
CA Certificate (PEM)-Optional CA certificate for server verification (PEM format). Uses the system CA store if not provided.
SAS Token TTL (seconds)3600SAS token validity period (300-86400 seconds). The token is automatically renewed at 75% of its TTL. Not applicable for X.509 authentication.
Keep Alive (seconds)230MQTT keep-alive interval (30-1177 seconds). Azure IoT Hub enforces a maximum of 1177 seconds.
Connection Timeout (seconds)30Timeout for establishing the MQTT connection (5-300 seconds)
5. Store & Forward
FieldDefaultDescription
Store & ForwardEnabledBuffer D2C telemetry locally during network outages. Failed messages are automatically retried when connectivity is restored.
Store & Forward Max Items10,000Maximum messages to buffer in the Store & Forward queue (100-100,000). Oldest messages are evicted when the limit is reached.
6. Device Twin
FieldDefaultDescription
Fetch Twin on ConnectEnabledRequest the full Device Twin document on connect and reconnect. Useful for synchronizing initial state.
7. Connection Labels
FieldDefaultDescription
Labels-Key-value pairs to categorize and organize this connection (max 10 labels)

Example Labels

  • environment: production - Deployment environment
  • site: factory-1 - Physical location
  • device-type: edge-gateway - Device classification
Notes
  • The connector uses MQTT 3.1.1 over TLS (port 8883) to communicate with Azure IoT Hub.
  • Azure IoT Hub supports QoS 0 and QoS 1 only. QoS 2 is not supported.
  • D2C message payload maximum size is 256 KB. Device Twin reported properties maximum size is 32 KB.
  • SAS Token TTL is hidden when X.509 authentication is selected, since X.509 does not use SAS tokens.
  • Store & Forward Max Items is only visible when Store & Forward is enabled.

Function Builder

Creating Azure IoT Hub Functions

After the connection is configured:

  1. Go to Functions -> New Function
  2. Choose a function type from the selection dialog
  3. Configure function-specific settings

Azure IoT Hub supports four function types organized into two categories:

Device-to-Cloud (Write) Operations:

Function TypeDescriptionTestable
D2C SendSend device telemetry to Azure IoT HubYes
Twin ReportUpdate Device Twin reported propertiesYes

Cloud-to-Device (Read/Subscribe) Operations:

Function TypeDescriptionTestable
C2D ReceiveReceive cloud-to-device messagesNo
Twin DesiredSubscribe to Device Twin desired property changesNo

D2C Send Function

Purpose: Send device-to-cloud telemetry messages to Azure IoT Hub with message routing properties, content type metadata, and configurable QoS.

Configuration Fields

FieldTypeRequiredDefaultDescription
Function NameStringYes-Unique name for this function (max 100 characters)
DescriptionStringNo-Optional description
Data PayloadString (JSON)Yes-JSON payload to send as D2C telemetry. Supports ((paramName)) parameter templates for dynamic values. Example: {"temperature": ((temperature)), "humidity": ((humidity))}
Content TypeStringNoapplication/jsonMIME type of the payload. Set to application/json for JSON message routing in Azure IoT Hub.
Content EncodingStringNoutf-8Character encoding. Required for JSON message body routing.
QoS LevelNumberNo1MQTT QoS level: 0 (at most once) or 1 (at least once). Azure IoT Hub does not support QoS 2.
Message Routing PropertiesKey-ValueNo-Key-value pairs appended as MQTT topic properties for Azure message routing (max 20 items). Values support ((paramName)) templates.
LabelsKey-ValueNo-Key-value pairs for organizing this function (max 10 labels)

Parameters: The function automatically detects ((paramName)) templates from the Data Payload and Message Routing Properties. Each detected parameter can be configured with a type, required flag, default value, and description.

Use Cases: Sensor telemetry publishing, device status reporting, event forwarding, periodic data uploads


Twin Report Function

Purpose: Update Device Twin reported properties to reflect the device's current state, capabilities, or metadata in Azure IoT Hub. Uses merge-patch semantics — only the provided properties are updated.

Configuration Fields

FieldTypeRequiredDefaultDescription
Function NameStringYes-Unique name for this function (max 100 characters)
DescriptionStringNo-Optional description
Reported Properties (JSON)String (JSON)Yes-JSON object of properties to report. Merge-patch semantics: only provided keys are updated. Supports ((paramName)) parameter templates. Example: {"firmwareVersion": "2.1.0", "operatingMode": "((mode))"}
Timeout (ms)NumberNo10000Maximum time to wait for IoT Hub confirmation (1000-60000 ms)
LabelsKey-ValueNo-Key-value pairs for organizing this function (max 10 labels)

Use Cases: Device firmware version reporting, operating mode updates, capability declarations, configuration acknowledgments


C2D Receive Function

Purpose: Receive cloud-to-device messages sent from Azure IoT Hub. This function type creates a subscription — it listens continuously for incoming C2D commands and passes them to connected pipelines.

Configuration Fields

FieldTypeRequiredDefaultDescription
Function NameStringYes-Unique name for this function (max 100 characters)
DescriptionStringNo-Optional description
Output FormatSelectNojsonHow to format the received message body: json (parse as JSON object), text (raw string), or base64 (binary as base64)
LabelsKey-ValueNo-Key-value pairs for organizing this function (max 10 labels)
note

C2D Receive is a subscription-based function and cannot be tested from the function builder. Use it with a C2D Trigger Node or an Azure IoT Hub Receive Node in the Pipeline Designer to receive messages.

Use Cases: Remote command execution, firmware update triggers, configuration pushes, device reboot commands


Twin Desired Function

Purpose: Subscribe to Device Twin desired property changes from Azure IoT Hub. Fires when cloud-side desired properties are updated, enabling the device to react to configuration changes.

Configuration Fields

FieldTypeRequiredDefaultDescription
Function NameStringYes-Unique name for this function (max 100 characters)
DescriptionStringNo-Optional description
Fetch Full Twin on SubscribeBooleanNofalseRequest the full Device Twin document when subscribing, to establish initial state
Property FilterArray of StringsNo-Specific JSON keys to listen for (e.g., targetTemperature, reportInterval). If empty, triggers on any desired property change.
LabelsKey-ValueNo-Key-value pairs for organizing this function (max 10 labels)
note

Twin Desired is a subscription-based function and cannot be tested from the function builder. Use it with a Twin Desired Trigger Node in the Pipeline Designer to receive desired property changes.

Use Cases: Remote configuration management, set-point adjustments, operating mode changes, feature flag updates


Using Parameters

Azure IoT Hub functions (D2C Send and Twin Report) support parameterized values via the ((parameterName)) syntax. Parameters are automatically detected from JSON payloads and routing properties.

ConfigurationDescriptionExample
TypeValidate incoming pipeline datastring, number, boolean, datetime, json, buffer
RequiredEnforce mandatory fieldsRequired / Optional
Default ValueProvide fallback values"line-01", 0, "{}"
DescriptionDocument intent for other authors"Temperature reading in Celsius"

Pipeline Integration

Use the Azure IoT Hub functions you create here as nodes inside the Pipeline Designer. The D2C Send and Twin Report functions appear as action nodes, while C2D Receive and Twin Desired functions power trigger nodes for event-driven pipelines.

If you are planning more complex orchestration, review the Connector Nodes page for patterns on where Azure IoT Hub nodes fit best within broader orchestration strategies.

Azure IoT Hub D2C Send node in pipeline designer

Azure IoT Hub D2C Send node with connection, function, and parameter mappings

Common Use Cases

Edge-to-Cloud Telemetry Pipeline

Publish normalized sensor data from shop-floor PLCs to Azure IoT Hub for cloud analytics, dashboards, and digital twins.

Typical flow: OPC UA/Modbus read -> Transform node -> Azure IoT Hub D2C Send node

Configure a D2C Send function with routing properties like messageType: telemetry and source: ((plantId)) to enable Azure IoT Hub message routing to downstream services (Event Hubs, Service Bus, Storage).

Remote Device Configuration

Subscribe to Device Twin desired property changes to dynamically reconfigure edge devices from the Azure portal or cloud applications.

Typical flow: Azure IoT Hub Twin Desired Trigger -> Condition node -> PLC Write / Configuration update -> Azure IoT Hub Twin Report (acknowledge configuration)

Cloud Command Execution

Listen for C2D commands from Azure IoT Hub and execute them as pipeline actions — write to PLCs, restart services, or trigger local operations.

Typical flow: Azure IoT Hub C2D Trigger -> JavaScript node (parse command) -> Conditional routing -> Action nodes

Device State Synchronization

Keep Azure IoT Hub in sync with the device's actual state by periodically reporting twin properties.

Typical flow: Schedule Trigger -> Read current state (OPC UA, Modbus, etc.) -> Transform -> Azure IoT Hub Twin Report node