I want to save and review all data received by Azue IoT Hub.

Hinata Katsunori 536 Reputation points


I would like to keep all data received by the IoT Hub in storage and review it later.

I could use the routing feature of the IoT Hub to store incoming data by making the endpoints storage, However, this would prevent Functions triggered by the IoT Hub from working.

Is there a way to make Functions work while routing incoming data to storage?

Thanks in advance.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,401 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,136 questions
{count} votes

Accepted answer
  1. Sander van de Velde 29,776 Reputation points MVP

    Hello @Hinata Katsunori ,

    as @AshokPeddakotla-MSFT already mentioned, by adding multiple routes, the same incoming message can be 'duplicated' to multiple endpoints, including Azure (Blob) storage.

    There is one little thing that could give the wrong impression.

    If you connect an Azure function using the IoT HUb trigger, you probably use the 'event hub compatible endpoint'.

    This endpoint is used to stream all telemetry to services:

    User's image

    But, if you add a first route (like one sending data to the blob storage endpoint) the 'event hub compatible endpoint' turns into a fall-back endpoint:

    User's image

    So, it only gets the messages not picked up by other routes...

    Because all messages are sent to the blob storage, your Azure function is not receiving any data ...

    This fallback route is a great addition but in your case, you just want a copy sent to the default event endpoint.

    Luckily, there is a simple solution.

    Just add a second route, sending all data to this pre-defined 'events' endpoint:

    User's image

    This just represents the endpoint and overrules the fallback functionality.

    This way, you both store telemetry in storage and have an Azure function react to real-time data:

    User's image

    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.

2 additional answers

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 28,406 Reputation points

    @Hinata Katsunori Greetings!

    I would like to keep all data received by the IoT Hub in storage and review it later.

    When you route the data to Azure Storage the data is still available and you can view under storage container. You can also Configure IoT Explorer to view messages

    Is there a way to make Functions work while routing incoming data to storage?

    Did you check this blog post How to use Azure Functions with IoT Hub message routing already? You can configure the IoT Hub to route incoming messages to a storage account and also to a custom endpoint that triggers an Azure Function.

    The Azure Function can then process the message and perform any necessary tasks, such as analyzing the data, triggering alerts, or sending notifications. This approach allows you to store all incoming data in a central location while also taking advantage of the capabilities of Azure Functions.

    See Custom endpoints and Azure IoT Hub trigger for Azure Functions for more details.

    Also, you can use Azure Event Grid to route incoming data to both storage and Functions. Azure Event Grid is a fully-managed event routing service that can be used to route events from various sources, including IoT Hub.

    Note that you can also use Azure Stream Analytics to route incoming data to both storage and Functions.

    Hope this helps. Do let us know if you need further help.

    If this answers your query, do click Accept Answer and Yes if this answer helpful. And, if you have any further query do let us know.

    2 people found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    Comments have been turned off. Learn more