0

for a demo, I would like to send data from Azure IoT Central to Azure Digital Twins similar to what I was able to successfully implement in the following scenario described here (https://learn.microsoft.com/en-us/azure/digital-twins/how-to-ingest-iot-hub-data).

In the above description, an Azure Function in C# is used, which is bound to an IoT Hub via an Event Grid Trigger.

Azure IoT Central does not have an event grid connection and the comments from here (https://learn.microsoft.com/en-us/answers/questions/266039/how-to-trigger-an-event-grid-from-an-iot-central-r.html) do not really help me.

Isn't there a simple and more feasible way to connect the two?

Would the following be possible?

  1. IoT Central receives the data from a device and forwards it as an export to a webhook.

  2. The webhook is an Azure function that converts the data from the device into the format of the digital twin and then forwards it to it.

Would this be a possible way or what would be the best way to do this?

I would really appreciate any tips, experiences, comments and code examples.

Best regards init5

Init5
  • 23
  • 4

1 Answers1

0

For your solution can be used a recently added a new feature of the Azure IoT Central such as Data transformation.

The Data transformation allows to create your custom payload for exporting to the specific destination, in your case via the webhook endpoint.

The following is an example to send the telemetry data to the Azure Event Grid custom topic:

Destination:

enter image description here

Data transformation:

{
  specversion:"1.0",
  id:.applicationId,
  source: .device.id,
  subject:"/myapp/vehicles/motorcycles",
  type:"recordInserted",
  time:.enqueuedTime,
  dataschema:"#",
  data:{
    timestamp: (now | strflocaltime("%Y-%m-%dT%H:%M:%S.%fZ") | tostring),
    telemetry: .telemetry | map({ key: .name, value: .value }) | from_entries,
    properties: .messageProperties
  }
}

Note, that the payload is for CloudEvents schema, but those mandatory properties can be moved to the headers and explicitly populated (the IoT Central didn't have capability to handle their value as an expression)

ce-id
ce-source
ce-specversion
ce-type

The same way you can make a data transformation for the destination endpoint Azure Digital Twin based on the document here.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • Hello Roman, Thank you for the answer and I need some time to try it out. But my first attempts have been quite positive so far. I would definitely document it and post it here so that others can also benefit from it. I would also be happy if you could take another look at it. Once again, thank you very much for your help, Roman. Many greetings Init5 – Init5 Sep 20 '22 at 15:14
  • 1
    Hello, got it working now. Actually I am not able post a solution here (not enough posts). For questions please contact me :) – Init5 Sep 28 '22 at 09:44
  • hi! I would like to know the solution. Is there any way you could share it with me, please? – Mr.J Dec 08 '22 at 11:10