0

I am having an issue with my Iot Hub to Digital Twins ingest function app. I am trying to update properties across multiple unique models with either a single or multiple ingestion functions but I can't figure out how to filter out the unnecessary telemetry. For example, I am wanting to do something like updating dischargeTemp and dischargePressure on a twin with model 1 while updating inletTemp and inletPressure on a twin with model 2. The function sees null values on one or another set of telemetry and throws an error. All of the example functions I have seen only assume a single type of device streaming telemetry and updating a single model. How do I determine what type of model is intended to be updated so that I can target only that model?

I tried writing a function that would process every possible type of telemetry but it throws errors due to null property values.

1 Answers1

0

This is a common challenge when translating device messages to updates in Azure Digital Twins. I wrote a reference implementation for this once.

My solution is to create a reference table with a bit of JSON for every DeviceId in IoTHub. The JSON contains the following:

  • The property to read from the telemetry message
  • The property to update in ADT
  • The type of the property (e.g. string, bool, int)
  • The twin ID in ADT

It's built so a single telemetry message can update multiple twins/properties in one execution. The Azure Function that executes these actions also doesn't care what ADT Model is being updated; it just fabricates patch messages and forwards them.

An alternative solution is to put this mapping table into a CSV file and use it as a reference file in Azure Stream Analytics, but that's a lot more costly for smaller workloads.

Matthijs van der Veer
  • 3,865
  • 2
  • 12
  • 22