Cannot view data pushed from IoT Hub through Azure Function on Azure Digital Twin

Goli, Shyam 20 Reputation points
2023-10-30T11:36:36.29+00:00

Actually I am trying to send the data of my device to the digital twin. For that i have choose to send the data to IOT hub and from their azure function will process the data and send data to the Digital twin.

I have created the IOT hub and created the Azure function and Digital twin is also setup. Now, When I am sending the data from the device to IOT hub and not able to view the data in the IOT explorer, but I would able see the graph in the IOT HUB overview is changing and showing data is getting published. and also i could be able to see that Azure function is also successfully processing the data but again could be able to view the data which it is processing and finally the data is not updating on the digital twin. I stucked badly and I need your help.

If there any resources to follow for end to end process so that I can solve my problem and any solutions for the problem?

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.
223 questions
0 comments No comments
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 13,951 Reputation points
    2023-10-30T16:58:03.03+00:00

    Hi @Goli, Shyam Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    not able to view the data in the IOT explorer

    Based on the information you have shared, it is highly likely that you are routing events to a custom End point on IoT Hub, which you are using to trigger the Azure function. In Azure IoT Explorer, when you try to view telemetry on a device, the default option that is selected for monitoring is built-in Event Hub end points. Please refer the below image to find this setting.

    User's image

    You can disable this setting and provide your Custom Event Hub endpoint to view telemetry through Azure IoT Explorer. You can also leverage Azure IoT Tools on Visual Studio Code to monitor custom endpoints. If you are new to the IoT Hub routing and would like to get more understanding on this concept, please refer to the following resources.

    Azure function is also successfully processing the data but again could not view the data

    I assume that you could not see the data being processed within the Azure functions. Here are a couple of possibilities you can try to get better understanding on the data being processed by your Azure function.

    • Put logger statements such as logger.info within your code and print out the data being received/processed. Once you redeploy the code and the function gets triggered, you can view the detailed messages for every invocation under monitor section of your Azure function. Please refer the below image for reference User's image
    • You can configure your Azure functions to run locally in Visual Studio Code and debug the code. Here is a link providing steps - Run Azure functions locally

    the data is not updating on the digital twin

    We would need more details on your Azure functions invocation messages/logs to get more details on how the data is being processed to better guide you on this issue. Here is a Tutorial on Azure Digital Twins- Build out an end-to-end solution which provides detailed steps on the same use case on how to simulate data from Azure IoT Hub and update a digital twin through Azure functions.

    Please note that if you are using a custom Model for your Azure Digital twin, you would have to update your Azure function code to update the corresponding property matching the model. If you run into any issues testing the code, please refer to a similar question, Telemetry Data from IOT hub not pushing to azure function and not reflecting to Digital Twin asked in the past where detailed explanations are given around the code functioning.

    Hope this helps. Please feel free to reach out to us with any additional questions through the comments.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 30,471 Reputation points MVP
    2023-10-30T16:51:44.35+00:00

    Hello @Goli, Shyam,

    welcome to this moderated Azure community forum.

    You are not able to consume IoT device messages in other services although messages are arriving in the IoT Hub.

    Do you use IoT Hub routing?

    Did you create a separate route for the built in 'events' endpoint?

    Check out the comment on the Azure portal:

    User's image

    By default, messages are routed to other services using the 'eventhub compatible endpoint'.

    This endpoint is used by the Azure IoT Explorer.

    Note: it is recommended to give every consuming service its own consumer group. This way each consumer gets its'own copy of incoming messages:

    User's image

    If you add new routes to the IoT Hub eg. to an Event Hub, or CosmosDB, that original endpoint will start behaving as a fall-back route. When not a single route is picking up an incoming message, it will be sent to the default events endpoint.

    Please add an extra route for this endpoint and the original functionality is restored:

    User's image

    Please let us know if this works for you.


    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 comments No comments