How to Restart the edgehub module using a custom Iotedge Module

Ls, Vaishnavi 41 Reputation points
2022-09-22T12:03:19.127+00:00

Is it possible to restart the Iotedge module using a custom module ?

Will the command "iotedge restart edgehub" can be triggered using a custom Module or any APIs available to restart the edgehub. I need to restart the edgehub only not the edge runtime. If there is any solution please do share

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

Accepted answer
  1. QuantumCache 20,031 Reputation points
    2022-09-22T18:49:04.883+00:00

    Hello @Ls, Vaishnavi ,

    Did you try from the Azure IoT Hub portal? Direct Methods

    244002-image.png

    Is you scenario very specific to do the edgeHub restart from a custom module? please add the use case or the scenario for the intermodule-communitcation or running a Host Terminal command on the device itself?

    Updated: Few other workarounds and thoughts , recommendations from Product Team

    The only other idea I have is to map the docker socket into the module (via container create options) and use the docker APIs to do the restart...

    {  
      "HostConfig": {  
        "Binds": [  
          "/var/run/docker.sock:/var/run/docker.sock"  
        ]  
      }  
    }  
    

    conceptually similar to how this does it, except restarting modules rather than cleaning up images...

    AzureIoTGBB/iot-edge-image-cleanup: Module for cleaning up unused docker images in iot edge (github.com)

    Giving modules access to the Docker socket directly essentially gives it root privileges on the device and not security best practice. Officially, we don't recommend this but neither do we do anything to explicitly block it. So the customer should independently evaluate the security risks involved with this approach and make their own call based on their risk appetite.

    Not sure about the options with IoT Central, but with IoT Hub you can think about a "device - cloud - device" roundtrip, so the device send D2C message, the IoT Hub route it to a certain Az function, the function invokes a direct method to restart the module...

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde 28,236 Reputation points MVP
    2022-09-22T23:43:44.9+00:00

    Hello @Ls, Vaishnavi ,

    Although I never tried this particular scenario, it probably could be done using that edgeAgent direct method.

    As mentioned by @QuantumCache , you will need to use inter-module direct method calls.

    Personally, I would use this solution with the utmost caution. I'm not sure what the side effects could be. Only use restarting the edgeHub as a last resort!

    4 people found this answer helpful.