The following screen snippets show an example of the user-id property on the telemetry data.
- The virtual device (represented by my Azure IoT Hub Tester) is publishing a telemetry data with systemproperty $.uid=ABCD1234
The telemetry data are receiving by azure function:
public static void Run2([IoTHubTrigger("messages/events", Connection = "AzureIoTHubConnectionString")]EventData message, ILogger log)
{
log.LogInformation($"\nBody:\n\t{Encoding.UTF8.GetString(message.Body.Array)}" +
$"\nSystemProperties:\n\t{string.Join("\n\t", message.SystemProperties.Select(i => $"{i.Key}={i.Value}"))}" +
$"\nProperties:\n\t{string.Join("\n\t", message.Properties.Select(i => $"{ i.Key}={ i.Value}"))}");
log.LogInformation($"user-id={System.Text.Encoding.UTF8.GetString(((ArraySegment<byte>)message.SystemProperties["user-id"]).Array)}");
}
The azure function log:
Note, that the value type of the user-id systemproperty is
ArraySegment<byte>