Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
580 stars 738 forks source link

A way to query IoT Hub from device and get response? #2611

Closed aleksandarkrstic closed 2 months ago

aleksandarkrstic commented 2 months ago

Hello,

I am using Azure C SDK to connect my device to IoT Hub and must say that everything is working fine for me and I didn't have any problems. However, I was wondering if there is a way to invoke some service or query IoT Hub from device side and get response (something similar to Direct Method but not cloud to device, rather like device to cloud "Direct Method" where device can query some service on the IoT Hub and get response as string for example)? Is that possible and how?

Thanks in advance.

ericwol-msft commented 2 months ago

although the iothub_service_client is depercated in this SDK, it's still functional. There are no current plans to remove this, other than no new hub features will be added.

Sample: https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_service_client/samples/iothub_devicemethod_sample/iothub_devicemethod_sample.c

aleksandarkrstic commented 2 months ago

Thanks, but isn't this still Cloud to Device direct method but from back-end app? I am looking for a way to "invoke" some "method" on IoT Hub and get response from IoTHub Client SDK if possible.

ericwol-msft commented 2 months ago

Are you looking for Azure Functions?

https://azure.microsoft.com/en-us/products/functions

ericwol-msft commented 2 months ago

https://learn.microsoft.com/en-us/training/modules/intro-azure-functions-iot/

ewertons commented 2 months ago

Closing this issue based on the last instructions from @ericwol-msft Please feel free to reopen this issue if you would like to follow up. Thanks, Azure IoT SDK Team