Looking for options to transfer telemetry message from one IoT Hub in a subscription to another IoT Hub in another subscription

Yashasvi Sai Jagannath Kolachina 40 Reputation points
2024-02-12T09:53:29.8033333+00:00

Hello Community, I'm currently looking for options(apart from azure function) related to transferring IoT Hub messages from one IoT Hub in a subscription to another IoT Hub in a different subscription within the Azure environment. I'm seeking guidance on the best practices or recommended approaches for achieving this. Scenario: IoT Hub A in Subscription A IoT Hub B in Subscription B

Challenge: I need to transfer messages from IoT Hub A to IoT Hub B efficiently. Questions: What are the recommended methods or best practices for transferring IoT Hub messages between different subscriptions? Are there specific tools, APIs, or Azure services that facilitate this process? Are there any considerations or potential challenges I should be aware of during this transfer?

Any insights or guidance from the community would be greatly appreciated. Thank you in advance!

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,133 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde 29,456 Reputation points MVP
    2024-02-12T13:26:08.3366667+00:00

    Hello @Yashasvi Sai Jagannath Kolachina,

    welcome to this moderated Azure community forum.

    The answer given by @AshokPeddakotla-MSFT is valid if you want to transfer messages from one IoT Hub to another one.

    I want to propose a different strategy.

    IoT Hubs are your gateways for incoming device-to-cloud messages. The only way to ingest telemetry is to create device clients and register each of them in an IoT Hub.

    I propose to keep devices sending telemetry to multiple IoT Hub is multiple regions but to skip "connecting the IoT Hubs".

    Just create a Stream Analytics Job in some subscription, in some region that is capable of ingesting telemetry from multiple IoT Hubs.

    Each IoT Hub is registered as input.

    The Azure portal does support adding IoT Hub from multiple subscription using the manual option: User's image

    You can also do this with the CLI:

    az stream-analytics input create --properties "{"type":"Stream","datasource":{"type":"Microsoft.Devices/IotHubs","properties":{"consumerGroupName":"sdkconsumergroup","endpoint":"messages/events","iotHubNamespace":"iothub","sharedAccessPolicyKey":"sharedAccessPolicyKey=","sharedAccessPolicyName":"owner"}},"serialization":{"type":"Avro"}}" --input-name "input7970" --job-name "sj9742" --resource-group "sjrg3467"

    Once messages are arriving from multiple IoT Hub inputs, use the UNION statement to combine the streams into one stream.

    Examples can be found here.

    Notice that each stream needs to expose the same set of columns so perhaps you need to rename iot hub input message properties.

    welcome to this moderated Azure community forum.

    This pattern is also useful for Azure IoT Hub failover situations.


    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

1 additional answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 28,131 Reputation points
    2024-02-12T10:26:54.42+00:00

    Yashasvi Sai Jagannath Kolachina Greetings & Welcome to Microsoft Q&A forum!

    Please see below answers to your queries.

    What are the recommended methods or best practices for transferring IoT Hub messages between different subscriptions? Are there specific tools, APIs, or Azure services that facilitate this process?

    There are a few options available for transferring IoT Hub messages between different subscriptions. One option is to use Azure Stream Analytics to read messages from IoT Hub A and write them to IoT Hub B. Another option is to use Azure Event Grid to route messages from IoT Hub A to IoT Hub B.

    Here are the steps to transfer messages from IoT Hub A to IoT Hub B using Azure Stream Analytics:

    • Create a new Stream Analytics job in Subscription B.
    • In the Inputs section of the Stream Analytics job, add IoT Hub A as an input.
    • In the Outputs section of the Stream Analytics job, add IoT Hub B as an output.
    • In the Query section of the Stream Analytics job, write a query to select the data from IoT Hub A and insert it into IoT Hub B.
    • Start the Stream Analytics job.

    Using Azure Event Grid:

    • Create an Event Grid subscription in Subscription A that subscribes to the events from IoT Hub A.
    • Create an Event Grid subscription in Subscription B that routes the events to IoT Hub B.
    • Start the Event Grid subscription.

    You can also Use Azure Logic Apps. It is a workflow automation service that can be used to transfer IoT Hub messages between different subscriptions. You can create a Logic App that reads data from IoT Hub A and writes it to IoT Hub B. This is a recommended method for transferring data between different subscriptions when you need to perform additional actions on the data before writing it to IoT Hub B.

    In general, it is recommended to use a fully managed service like Azure Stream Analytics or Azure Event Grid for transferring IoT Hub messages between different subscriptions because they are efficient, reliable, and scalable.

    However, if you need to perform additional actions on the data before writing it to IoT Hub B, you can use Azure Functions or Azure Logic Apps.

    You also can create custom endpoints that point to other services in your Azure subscription.

    Are there any considerations or potential challenges I should be aware of during this transfer?

    One thing to consider is the cost of transferring data between IoT Hub A and IoT Hub B. You may incur data transfer charges depending on the amount of data transferred and the location of the IoT Hubs. Do let me know if that helps or have any other queries.

    If the response helped, please do click Accept Answer and Yes for was this answer helpful.

    Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments