Search code examples
azure-service-fabricazure-iot-hub

SystemProperties not populated for Azure.Messaging.EventHubs.EventData?


We have recently upgraded our Service Fabric service that reads messages from Azure IoT Hub built-in Event Hub from the deprecated Microsoft.Azure.EventHubs SDK to Azure.Messaging.EventHubs SDK (following this migration guide).

We are running into an issue where the SystemProperties for the EventData class are not fully populated. Specifically, message-id, correlation-id, and user-id properties come in with no data, as seen here:

{"message-id":{},"user-id":{"Length":0,"IsEmpty":true},"correlation-id":{},"iothub-connection-device-id":"xxxxxxx","iothub-connection-auth-method":"{"scope":"device","type":"sas","issuer":"iothub","acceptingIpFilterRule":null}","iothub-connection-auth-generation-id":"xxxxxxxxxxxxxxxxx","iothub-enqueuedtime":"2023-07-13T22:00:53.501Z","iothub-message-source":"Telemetry","x-opt-sequence-number":4785508,"x-opt-offset":1005023123136,"x-opt-enqueued-time":"2023-07-13T22:00:53.652+00:00"}

We are using an EventProcessorClient with the AmqpTcp transport type.

Can anyone help us in determining why these system properties are not being populated? This worked previously with the deprecated SDK.

Any help is appreciated.


Solution

  • According to this MSDOC the events that are received through the Event Hubs service have these characteristics filled. The events received from other sets empty.

     static async Task ReceiveMessagesFromEventHub()
        {
            await using var consumerClient = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString, eventHubName);
              await foreach (PartitionEvent partitionEvent in consumerClient.ReadEventsAsync())
            {
                EventData eventData = partitionEvent.Data;
                object messageId = eventData.Properties["message-id"];
                object correlationId = eventData.Properties["correlation-id"];
                object userId = eventData.Properties["user-id"];
                object Iotubconectiondevidid = eventData.Properties["iothub - connection - device - id"];
                object iothubconnectionauthmethod = eventData.Properties["iothub - connection - auth - method"];
    

    Refer this for Missing IoT Hub System Properties and SO.

    Event From Iot Hub:

    enter image description here

    Event from Event Hubs:

    enter image description here