0
votes

When my IoT Hub routes a device message to the built-in "Events" endpoint, the message's meta data (Message ID, Device ID, Enqueuing Time, etc.) is contained in the event. When the same message is routed to my custom endpoint (an Event Hub), the message's meta data is not contained in the event. Is there an option for forwarding the IoT Hub message meta data to custom endpoints?

Examples:

IoT Hub -> "Events" Endpoint -> Sampled input at stream analytics

{
    "type": "Flow",
    "payload": {
        "timestamp": "2018-08-02 08:05:11.991",
        "flow": 1
    },
    "EventProcessedUtcTime": "2018-08-02T08:06:04.3909310Z",
    "PartitionId": 1,
    "EventEnqueuedUtcTime": "2018-08-02T08:05:13.2180000Z",
    "IoTHub": {
        "MessageId": null,
        "CorrelationId": null,
        "ConnectionDeviceId": "...",
        "ConnectionDeviceGenerationId": "636657651873407150",
        "EnqueuedTime": "2018-08-02T08:05:13.0320000Z",
        "StreamId": null
    }
}

IoT Hub -> Custom Endpoint -> Event Hub -> Sampled input at stream analytics

{
    "type": "Flow",
    "payload": {
        "timestamp": "2018-08-02 05:41:37.714",
        "flow": 0
    },
    "EventProcessedUtcTime": "2018-08-02T05:53:58.3994321Z",
    "PartitionId": 1,
    "EventEnqueuedUtcTime": "2018-08-02T05:41:38.8890000Z"
}
1
I can't reproduce your issue. I can get like device id of the system property both using build-in events endpoint and custom endpoint Event Hub. Can you show how do you get the system properties?Rita Han
Hi Rita, I just added examples to the post.Fabian

1 Answers

1
votes

When your data comes from an Event Hub stream input, you have access to the following metadata fields:

  • EventProcessedUtcTime
  • EventEnqueuedUtcTime
  • PartitionId

As you have already found. See this document: "Stream data from Event Hubs".

When using Event Hub as an endpoint for IoT Hub Routes, you can access to the IoT Hub medadata using the GetMetadataPropertyValue function.

Here is an example:

To query from Event Hub with IoT Routing enabled,

SELECT 
GetMetadataPropertyValue(ehInput, '[EventHub].[IoTConnectionDeviceId]') AS myIoTDeviceId 
FROM ehInput