How to send a file/patch/message from IOT hub to IOT Edge device

Krithick Kalyan T 0 Reputation points
2024-04-27T17:05:10.4566667+00:00

I want to upload a patch or Json file to the IOT Edge device from IOT hub.

I have connected the Edge device to the hub via DPS and have been able to send messages and trigger downloads from the hub from the Edge side using this. And I can send telemetry messages from Edge device to hub.

I did see it is possible to send messages to IOT devices but not IOT Edge devices. If i want to a message alerting the edge device to download or pushing the file from hub to the Edge device, how can i go for it?

I am using the Azure portal in the browser and not using the CLI or code for the IOT hub.

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
576 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,200 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 32,891 Reputation points MVP
    2024-04-27T21:49:23.8166667+00:00

    Hello @Krithick Kalyan T ,

    welcome to this moderated Azure community forum.

    You tell you use the Azure portal to manipulate devices registered within the Azure IoT Hub.

    You have been able to connect an Edge device (a special kind of IoT Hub device) so you should understand it is build up in modules.

    Where a regular 'direct internet connected' IoT device can be manipulated using its device twin (using eg. desired properties, reported properties, direct method, cloud message) an Azure IoT Edge device does not have these abilities.

    It's the modules, each with their module twin that can be manipulated with their desired properties, reported properties, and direct methods.

    So, if you want to send a file to an Azure IoT Edge device using the Azure IoT hub in the portal, you need to manipulate one of the modules running inside that edge device.

    What you need is:

    • a (custom) module
    • access to the operating system for that module
    • a way to trigger a file download by the module
    • preventing cloud access to the file marked for download

    I'm not aware if there are of-the-shelf modules available capable of reading a file from the cloud. I expect you need to write one yourself.

    How can you send a file to a module?

    Putting a file inside a desired property is not feasible due to the limited 32KB size available in a module twin.

    A direct method can be used up to 128 KB.

    I recommend putting the file in eg. an Azure Storage blob container and sending the file path over a desired property.

    The module receives the module twin change event and downloads the file.

    then, you need to provide your custom module access to the operating system because containers normally run 'sandboxed'.

    This can be done with a 'bind' as seen in this blog post.

    There is one more thing to think about, securing cloud access to the file.

    You can provide the security credentials for the container in the desired properties. A better way is to use a SAS token for granting limited access to the file, living in the storage container.

    I understand that there are quite a few steps needed before a file can be uploaded but this is how it can be done, at scale, for any size and secure.


    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.


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.