Using a separate Event Hub
Last updated
Last updated
In addition to the built-in Event Hub of your IoT Hub you can use a separate Event Hub as well.
An Event Hub receives messages from IoT Hub through message routing or via an Azure Function transformation.
It's also possible that you do not use an IoT Hub at all, but send messages to the Event Hub by other means. For example when devices communicate via a legacy protocol not supported by IoT Hub. There is a custom protocol endpoint, e.g. realized using an Azure Function, that the devices connect to.
Data is received not from devices directly but via some other cloud.
In Scenario 1 all hooks can be used. You only need to configure ux4iot with the connection string of the Event Hub instead of the connection string of the Event Hub compatible endpoint of IoT Hub. In scenario 2 and 3, which do not include an IoT Hub at all, the following hooks can be used:
useMultiConnectionString
When you send messages to Event Hub, they must adhere to the following requirements:
They must have a property iothub-connection-device-id
containing the device identifier
They must have a property iothub-message-schema
. The value of this property must be Telemetry
.
You can optionally set the timestamp of the data with the iothub-creation-time-utc
property. The value must be in ISO 8601 format, e.g. "2022-01-01T12:00:00.000Z". If it is not set, the current server timestamp is used instead.
If you send the messages from IoT Hub through message routing, these properties are automatically set. If you're using the eventhub instead, the ux4iot consumes messages and tries to determine which timestamp to use.
Timestamp Resolution:
if the timestamp is not defined afterwards it will use
if the timestamp is still not defined it will use the time that the message is consumed by ux4iot.
Here is an example of sending a message to an Event Hub using Node.js:
Instead of passing the device ID and the timestamp through message properties, you can also specify them inside of the message. You need to configure your ux4iot instance with the parameters: customTimestampKey
and customDeviceIdKey
. If you e.g set them to _ts
and deviceId
respectively, you can also send the following message: