4
votes

We currently have devices which are sending files to Azure through an Azure IoTHub using the file upload functionality.

Ideally we would have an Azure Function which gets triggered when there is a new File uploaded. We are aware of the fileuploadnotifications rest API but with this we need to use a timertriggered Azure Function and need to poll this API.

Is there a way to let the IoTHub trigger the azure function when there is a new file upload?

EDIT 1

I just tried to hook up the function to the event hub, but instead of event hub name messages/events I used messages/servicebound/fileuploadnotifications according to the suggestion made by Matt Mason - MSFT. In this functions which was bound to the fileNotifications path I only received the messages I sent to the IoTHub and receive no file upload notifications. See the screenshot below.

enter image description here

2
It looks like this question is also answered on this forum: social.msdn.microsoft.com/Forums/en-US/…Wessel Kranenborg

2 Answers

0
votes

Edit - unfortunately the FileUploadNotification api is not supported for event hubs. However, you can work around this by sending a device message on file upload to an event hub compatible endpoint, see here:

https://social.msdn.microsoft.com/Forums/en-US/e0cc88e6-9592-4f4f-ba25-8fa4afa2fcf1/consume-iot-hub-file-upload-notifications-as-triggered-events?forum=azureiothub


Looking at the FileUploadNotifications api, it appears that it is a service-facing endpoint:

As explained in Endpoints, IoT Hub delivers file upload notifications through a service-facing endpoint (/messages/servicebound/fileuploadnotifications) as messages.

I believe you'll be able to follow these instructions to hook up the function to the event hub, but instead of event hub name messages/events, use messages/servicebound/fileuploadnotifications.

0
votes

A straight-forward way is to create an EventGrid subscription for an Azure function to a "Blob Created" event on the Container where the files will be uploaded via the IoT hub.