IoTHub ingest function to azure digital twin (failed)

TEE WEI KIAT 40 Reputation points
2024-04-03T01:54:09.4+00:00

I have created a function app for iot hub ingest telemetry data to azure digital twin using visual studio 2022 and the function is successfully being published but the data is fail to deliver. The following is my function app code:
User's imageUser's image

The figure below is from the application insights of my function app :
(im new to azure so i have little idea how to solve these issue)User's image

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
231 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,118 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,202 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,004 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 33,136 Reputation points MVP
    2024-04-03T06:26:03.6033333+00:00

    Hello @TEE WEI KIAT,

    welcome to this moderated Azure community forum.

    The error message tells is the CloudEvent cannot be converted.

    It seems a string is ingested?

    Please try to find out what type of parameter contains the incoming message first.

    Because you use a EventGridTrigger, my first thoughts are about 'EventGridEvent'.

    Check out my blog post on using Azure Digital Twins. It contains a GitHub example based the IoT Hub EventGrid output. There the message is ingested as a 'EventGridEvent'.

    For an EventHub, you typically use the EventData class.

    But perhaps you just need to stick to 'string' first.

    Let us know if this helps.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.