Can we invoke one module's leaf device direct method from another module?

Nirav Prabtani 96 Reputation points
2020-08-20T11:17:02.427+00:00

I have developed two custom IoT edge modules
e.g. Module1, Module2

Module1 is having multiple IoT devices (Leaf devices) running inside the container.

Those leaf devices have certain direct methods written e.g. IsDeviceOnline

Is it possible to invoke that direct method from Module2?

I have tried by writing leaf deviceId while invoking as below but it gives

{"status":500,"payload":null}

always.

MethodRequest request = new MethodRequest("IsDeviceOnline");
var resp = await moduleclient.InvokeMethodAsync(deviceId, "Module1", request);

Above code is getting executed from Module2

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
383 questions
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.
543 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nirav Prabtani 96 Reputation points
    2020-08-20T12:40:40.943+00:00

    I got the solution...

    I have just removed moduleId and it is working fine

    MethodRequest request = new MethodRequest("IsDeviceOnline");
             // Execute request
             var resp = await moduleclient.InvokeMethodAsync(deviceId, request);
    

0 additional answers

Sort by: Most helpful