Search code examples
c#ciotazure-eventhubazure-iot-hub

How do I set certain system properties with the Azure IoT C SDK for the AMQP protocol and where do they end up in the EventHub?


edit: Add more information, see end

In the C# IoT SDK, I can set certain properties on the message class. There are no equivalent options at Message Handles in the C SDK, however.

How can I set the following properties with the C SDK:

  • To
  • UserId

Furthermore, how do I access them on the receiver side in C# via the EventData Class and the C SDK with the EventData Class? In the C# class the message properties are split in system properties and properties, whereas in the C class there are only properties. I can only set these properties in the property map when I use the C IoT Hub.

I can't seem to find entries for the following keys in the system properties map:

  • "user-id"
  • "to"

I can find them in the normal property map, however. When I set them in the C# SDK with the specialized setters, they should appear in the system properties map.

Why does this happen and how can I get this working for both cases? And what are the actual mappings between the C# message class setters and the EventHub system properties and properties?

edit:

Maybe I should be somewhat more specific. I am using the AMQP protocol and according to the standard page 74-78 (Sorry I cannot post a link, due to missing reputation) a message contains "properties", i.e. the properties I can set with SetCorrelationId, and "application properties", which are the properties I can set with the Map_AddOrUpdate method.

I would expect the following:

When receiving the message with the EventHub I expected to have the fields "to" and "user-id" in the system properties map, since those are the names mentioned in the standard. By debugging I was able to see entries in the system properties map which were semantically what I expected, but under different names.

Since that means the properties are probably send, there must be some sort of mapping which corresponds to:

  1. AMQP standard property name <-> Eventhub system property name
  2. C SDK "system properties" name (automatically inferred or not) <-> Eventhub system properties name

Solution

  • 2017.03.07:

    At the current point in time it seems to be a bug / mismatch between the IoT Hub documentation, the AMQP specification, the C and the C# SDK. See github issue.

    For a workaround look at @RitaHan-MSFT's answer.