0
votes

I'm using iot edge modules. I need to send messages to the hub from the edge module. Per my understanding, I need to send it first to the iot edge hub, the edge hub will take care of transferring it to the cloud iot hub. I can consume it from there.

If that's supported, I'm looking for a REST sample on how to do that (or just REST documentation)

2

2 Answers

0
votes

To send data to the IoT Edge hub, a module calls the SendEventAsync method.

ModuleClient client = new ModuleClient.CreateFromEnvironmentAsync(transportSettings); 
await client.OpenAsync(); 
await client.SendEventAsync(“output1”, message); 

Checkout the below link for moduleclient class methods and properties.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.devices.client.moduleclient?view=azure-dotnet

0
votes

You don't necessarily have to use the ModuleClient SDK if you want to sent messages through IoT Edge to the cloud. The alternative would be to use IoT Edge in a transparent gateway mode: https://docs.microsoft.com/en-us/azure/iot-edge/how-to-connect-downstream-device

In this way your (virtual) device could connect to the Edge Hub just as it would connect directly to the IoT Hub - using AMQP, MQTT or - as you want to - HTTP.