2

I have set up an Azure IoT Edge Module, and it works quite fine when deploying it to a IoT Edge Runtime via Azure.

However, I am not able to find a way how to interact with the module while locally debugging it. What I need to do is to invoke direct methods on it and modify the module twin while it's running.

Additionally I have the question: Where does the Local debugging Module actually connect to? Does it open a connection to the Azure IoT Edge Device using the connection string configured in the "IoT Edge Tools" in Visual Studio? At least it does not seem so, since it does not read the settings of the Module Twin from Azure IoT Hub.

Other Question: On an Edge solution in Visual Studio , when I right click on the Project Node, I have the possibility to "Build and Push the Module" to Azure Container Registry, and to run it in the Simulator. I assume that running it in the simulator is not the same like debugging it?

Thank you very much in advance!

kolbi
  • 147
  • 8

1 Answers1

3

When you debug a module in Visual Studio, the template start iotedgehubdev (aka the simulator) in a single module mode.

With this mode you can send message to your module via a REST api

curl --header "Content-Type: application/json" --request POST --data '{"inputName": "<input_name>","data":"hello world"}' http://localhost:53000/api/v1/messages

It launch also your module and name it "target"

iotedgehubdev modulecred -l -m "target"
   EdgeHubConnectionString=HostName=<hostname>;GatewayHostName=localhost;DeviceId=<your-edge-device-id>;ModuleId=target;SharedAccessKey=<key>
   EdgeModuleCACertificateFile=C:\ProgramData\iotedgehubdev\data\certs\edge-device-ca\cert\edge-device-ca.cert.pem

The module target will be accessible in azure portal - iothub. You can use the interface to call methods and change twin module enter image description here

And finally, run in simulator isn't the same as debugging. When you use that command, VS run iotedgehubdev in mode simulator, which will run all the modules in your deployement file and apply the routes, configs, etc.

You can still debug the module but you have to use a remote debugger which is a whole other subject.

Zied
  • 1,696
  • 12
  • 20