0
votes

I'd like to know if this is possible more than anything - then maybe steps on how to accomplish it.

I have a Pi with a camera, this should take a picture and upload to a blobContainer using azure iot hub

I want to be able to process that image, but also send a message back to the device. i.e - I need to know the DeviceId then send a message back to the device (Pi). I want to achieve this step using an Azure Function... I was previously able to send messages D2C, process in azure functions then (C2D) send back a message to the device in question like in this link

http://www.10thmagnitude.com/tech-blog/step-step-guide-creating-functions-within-azures-iot-hub/

I need to be able to know the device an image came from - can this be done?

1
Not sure what exactly you are asking, since you said you were able to send messages both directions. Do you know how to make it work without Azure Functions? Is your Device ID in EventData that you receive?Mikhail Shilkov
@Mikhail, the goal is to know the deviceID for a device that uploaded the image (then an event hub triggered Azure Function can use uploadedImage and the device Id and send a message back)... i got it working with sending string Messages - as per the second linkraklos
If that's the only thing, you can substitute string type to EventData in your function argument (step 5) to get message metadataMikhail Shilkov
@Mikhail, basically, using the upload in the first link can this trigger an eventhub trigger function? - i know i could use blobtrigger function but then I will lose device id...raklos
You can use Event as input trigger and Blob input binding to retrieve the related file. File path can be determined based on the properties of the event, if event is an instance of a strongly typed class.Mikhail Shilkov

1 Answers

1
votes

In the tutorial you refer to Upload files from your simulated device to the cloud with IoT Hub, there is a simple console application that receives the file upload notifications (you are planning to replace this with an Azure Function if I understand you correctly). The console application retrieves the blob name using:

fileUploadNotification.BlobName

The FileNotification object also has a DeviceId property that gives you the device id you need.

If your Azure Function is reading from the /messages/servicebound/fileuploadnotifications endpoint, it receives a message with the deviceid of the device that uploaded the blob. See File upload notifications. Can your Function use blob trigger function and then read from the /messages/servicebound/fileuploadnotifications endpoint, or even just run on a timer and periodically check the endpoint?