I have a NodeJS
app that can successfully send data to the Azure IoT Hub
, which in turn sends the data to the Azure Blob Storage
.
That all works fine.
I can also manually send a message with the Message to device
tool of the Azure Devices
portal and I can receive this message in my NodeJS app.
What I want to do now, is to send a confirmation message back to the NodeJS app when the blob has been created or deleted.
Can someone please guide me on how to do that? There is little information out there to send messages back to the Azure Client
.
I see that I can create a subscription to the Azure Blob Storage
but I don't know how to hook it up to the Azure IoT Hub
.
Cheers
CodePudding user response:
This is possible by using an Azure Function with a Blob Storage trigger. You could write an Azure Function that subscribes to blob storage changes and use the IoT Hub Service SDK to send a message back to the device. I'm assuming you're using IoT Hub's message routing feature to store the telemetry in blob storage. This comes with a challenge, as there is no way to tell from the name of the blob what device it originated from. You would need to combine it with a blob input to read the file input.
Do you absolutely need this confirmation on the device side? Another note, if you're not interested in persisting telemetry, but instead want to upload a file from your NodeJS app, you could consider the IoT Hub File Upload feature instead.
CodePudding user response:
You can use a device twins to represent a state between the device and service sides. Updating a state (device twin) at the service side, the notification message is delivered to the device side.