Skip to main content
Version: 3.0 (next)

Azure IoT Edge Integration Guide

Azure IoT Edge runs containerised modules on a factory edge device. A local edge hub routes messages between the modules and to Azure IoT Hub, and buffers them while the device is offline.

The Azure IoT Edge connector makes MaestroHub a module on that device. MaestroHub talks only to the local edge hub, never directly to the cloud; edge routes decide where its messages go.

Overview​

The connector provides:

  • Send to Output — publish a message on a named module output. Routes deliver it to IoT Hub ($upstream) or to another module's input.
  • Report Module Twin Properties — patch the module twin's reported properties, so the cloud can query edge status.
  • Read Module Twin — read the desired configuration and reported properties with their versions.
  • Receive on Input — start a pipeline for each message routed to one of MaestroHub's module inputs.
  • Module Twin Desired Changes — start a pipeline when the cloud changes MaestroHub's desired properties.
  • Direct methods — let a cloud application call a method on MaestroHub and get the pipeline's answer.
  • Two authentication methods — through the IoT Edge runtime with nothing secret stored, or with a module key.
  • Edge CA trust only — the edge hub's certificate is verified against the edge device's own CA. Public roots are never trusted and verification is never skipped.
  • Store & Forward for Send to Output and Report Module Twin Properties while the edge hub is unreachable.
Two buffers, two jobs

The edge hub buffers messages while the device is offline from Azure (for the route's time to live, 2 hours by default). MaestroHub's Store & Forward buffers them while the edge hub itself is unreachable from MaestroHub — for example while it restarts.

Connection Configuration​

Navigate to Connections → New Connection → Azure IoT Edge.

Authentication​

MethodWhen to useWhat you enter
IoT Edge runtime (default)MaestroHub is deployed as an IoT Edge moduleNothing. The identity comes from the module's IOTEDGE_* environment, and the IoT Edge runtime signs its tokens and supplies the edge CA.
Module keyMaestroHub runs next to the IoT Edge runtime, not as a moduleThe module identity, its key, the edge hub host and the edge CA certificate

When MaestroHub is not running as an IoT Edge module, IoT Edge runtime is shown disabled with the reason.

Module key fields​

FieldRequiredDescription
IoT Hub HostnameYesThe IoT Hub the edge device belongs to, e.g. myhub.azure-devices.net
Edge Device IDYesThe IoT Edge device identity
Module IDYesThe module identity MaestroHub connects as
Module KeyYesThe module identity's primary or secondary key (Base64). Stored encrypted.
Edge Hub HostYesHost name of the edge device. MaestroHub dials it and checks the edge hub certificate against it.
Edge Hub PortNoDefault 8883, where the edge hub listens inside the edge network. Also applies under IoT Edge runtime authentication, if the edge hub is published on another port.
Edge CA Certificate (PEM)YesThe edge device's root CA certificate

Advanced fields​

FieldDefaultDescription
TLS Server NameEdge Hub HostThe name the edge hub certificate is issued for, when it differs from the host you dial
Workload API SocketIOTEDGE_WORKLOADURIOverride for the IoT Edge workload API socket (unix:///…). IoT Edge runtime authentication only.
SAS Token Lifetime1hBetween 5m and 24h. The connection renews its token by reconnecting at 80% of the lifetime.
Keep Alive60sBetween 10s and 29m, and less than half the token lifetime
Connection Timeout30sBetween 5s and 300s

One connection per module identity​

The edge hub keeps one session per module identity: when a second client connects as the same identity, the edge hub closes the first. MaestroHub therefore refuses to create a second connection — in any organization on the same instance — that uses a module identity another connection already uses. Cloning an Azure IoT Edge connection is refused for the same reason.

Test Connection on a connection that is running opens a second session with the same identity, so it briefly interrupts the running connection, which then reconnects.

Test Connection also reads the module twin, which needs IoT Hub. When IoT Hub does not answer (for example, the hub's daily message quota is used up, or the hub is throttling), the test still succeeds, because the local link works, and it shows a warning that twin functions fail until the hub answers. Sending to outputs and receiving inputs keep working meanwhile.

Functions​

Send to Output​

ParameterRequiredDescription
Output NameYesThe module output. Routes select messages by it: FROM /messages/modules/<module>/outputs/<name>. Must not contain /, # or +.
DataYesThe message body. Text is sent as-is; a JSON value is sent as JSON.
Message PropertiesNoApplication properties that route queries can filter on. Names starting with $ or iothub- are reserved and rejected.
Content TypeNoDefault application/json
Content EncodingNoDefault utf-8. Route queries on the body need application/json and utf-8.
Message IDNoLeave empty to generate a unique ID for each message. A message resent by Store & Forward also gets a new ID, so consumers cannot use it to spot duplicates.
Correlation IDNoCarried with the message
QoSNo1 (default) waits for the edge hub to acknowledge; 0 does not.

Success means the edge hub accepted and stored the message — not that it was delivered. A message whose output no route matches is dropped by the edge hub, and MaestroHub cannot see routes. The result names the output so you can check it against your routes.

Result:

{ "outputName": "telemetry", "topic": "devices/edge-01/modules/maestrohub/messages/events/%24.on=telemetry&…", "bytesWritten": 156, "qos": 1, "messageId": "…" }

Report Module Twin Properties​

ParameterRequiredDescription
Reported PropertiesYesJSON object merged into the reported properties. A null value deletes that property.

Result: { "statusCode": 204, "version": "12", "bytesWritten": 89 }

Read Module Twin​

ParameterDefaultDescription
Sectionallall, desired or reported

Result: { "section": "all", "desired": { …, "$version": 4 }, "reported": { …, "$version": 12 } }

Receive on Input​

Starts a pipeline for each message an edge hub route delivers to one of MaestroHub's module inputs. See the Azure IoT Edge Triggers.

ParameterRequiredDescription
Input NameYesThe input, as named in the route's BrokeredEndpoint("/modules/<module>/inputs/<name>"), or * for every input

Module Twin Desired Changes​

Starts a pipeline when the desired properties of MaestroHub's module twin change.

ParameterDefaultDescription
Property Filterevery changeTop-level desired property names to react to
Sync Full TwinonDeliver the full desired properties when the pipeline is enabled, and after a reconnect if they changed while MaestroHub was away

Receive Direct Method​

Starts a pipeline for each direct-method call a cloud application makes on MaestroHub's module, for example az iot hub invoke-module-method --method-name setRecipe.

ParameterDefaultDescription
Method Name— (required)The method to handle, or * for every method
Response Budget25sHow long the pipeline has to answer. Keep it below the caller's timeout (30 s by default); IoT Hub does not tell the module the caller's timeout.
Answer 504 When LateonAnswer the caller with 504 and the reason when the pipeline has not answered within the budget

A call for a method no pipeline handles is answered 501 at once.

Respond to Direct Method​

Answers a call received by Receive Direct Method.

ParameterRequiredDescription
Request IDYes{{ $trigger._metadata.requestId }} from the trigger
StatusNoDefault 200; 100–599
PayloadYesJSON returned to the caller, up to 128 KB. Text that is not JSON is sent as a JSON string.

A call is answered once, and only while its caller waits: not after the response budget ran out, and not after MaestroHub's connection to the edge hub restarted since the call arrived (the caller got 503). This function is never buffered by Store & Forward.

Running MaestroHub as a module​

To deploy MaestroHub as an IoT Edge module — the module definition, routes and the edge hub's offline time to live — follow Run MaestroHub as an Azure IoT Edge Module.

Delivery guarantees​

Delivery is at least once. The edge hub does not deduplicate, and a message can be sent twice when the connection drops before the edge hub's acknowledgement arrives. Deduplicate downstream on the message ID.

Limits​

LimitValueWhat happens above it
Message size (body and properties)256 KBRefused permanently, never retried. With Store & Forward enabled on the connection, the message goes straight to the dead-letter queue; without it, the node fails.
Reported-properties patch32 KBSame
Direct-method answer128 KBThe Respond to Direct Method node fails at once

What the connector cannot see​

  • Routes. A module cannot read the edge hub's routes. An output with no matching route is dropped silently by the edge hub.
  • Upstream time to live. While the device is offline from Azure, the edge hub keeps messages for the route's time to live (2 hours by default) and then drops them. Raise timeToLiveSecs in the edge hub's deployment if outages can last longer.

Starting without internet​

When the device starts with no connection to Azure, the IoT Edge runtime tries to reach IoT Hub before it uses its cached identities. With IoT Edge runtime authentication, it can then take a few minutes to sign MaestroHub's token. Until it does, the connection keeps retrying and its error says it is still waiting for the runtime. It connects on its own as soon as the runtime answers, while the device is still offline, and local routes and pipelines work from then on.