How to handle IoTHub file upload notifications in Azure Function

We currently have devices that upload files to Azure via Azure IoTHub using the file upload functionality.

Ideally, we'll have an Azure function that fires when a new file is uploaded. We know about the fileuploadnotifications rest API , but with this we need to use the Azure Function with titles and need to poll this API.

Is there a way to let IoTHub trigger an azure function when a new file is loaded?

EDIT 1

I just tried to hook up the function to an event hub, but instead of event hostname messages / events, I used messages / servicebound / fileuploadnotifications as suggested by Matt Mason - MSFT. In these functions, which were tied to the fileNotifications path, I only received messages sent to IoTHub and did not receive file upload notifications. See screenshot below.

enter image description here

+3


source to share


1 answer


Edit - unfortunately the AppUploadNotification api file is not supported for event hubs. However, you can work around this by sending a device message about the 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 seems like this is a service-facing endpoint:

As explained in Endpoints, the IoT Hub provides file upload notifications through the service endpoint (/ messages / servicebound / fileuploadnotifications) as messages.

I believe you should be able to follow these instructions to hook up a function to an event hub, but instead of the event hostname messages/events

, use messages/servicebound/fileuploadnotifications

.

0


source







All Articles