'Azure Iot Hub Direct Method Call from front end Node.js Website

I am doing my final year project Using Azure Cloud. I have connected my raspberry pi where I have deployed my python code to trigger the device connected to its GPIO pins. These pins are triggered by "Azure-iot-Hub direct method call". How can I integrate this thing in website? I want to create a button on website and every time when I will press this button the direct method should be called. Is there any way to do this?



Solution 1:[1]

Unless creating website is in the scope of project, the easiest option is to use IoT Central, create a device template with associated telemetry, properties and commands.

If creating a custom website, wire the direct method IoT Hub Rest API to your application web page. https://docs.microsoft.com/en-us/rest/api/iothub/service/devices/invoke-method

or use the nodejs service client https://github.com/Azure/azure-iot-sdk-node/blob/main/service/samples/javascript/invoke_command.js

Depending on what web stack you are using, the appropriate SDK can be used (nodejs, python, c#, c or java)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 humblejay