Azure Function with IoT Hub Trigger and Cosmos DB output

Matt Heagerty 46 Reputation points
2020-09-11T21:25:17.92+00:00

I have an IoT device that sends data in a binary format to an IoT Hub.

From there, I need to store the data in Cosmos DB, after presumably converting it to JSON format.

My idea has been to set up an Azure Function with an IoT Hub trigger and a Cosmos DB output. The function code itself would handle the data conversion.

Does this seem like an appropriate approach? I was going to use a Cosmos DB Table but saw somewhere that the Function App output bindings only support the SQL API, is that true?

For reference, I have a JavaScript code to convert from binary to JSON, and my IoT hub is successfully receiving the device messages and triggering the Function App.

Any help is greatly appreciated,
Thank you

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,426 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,137 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,478 questions
{count} vote

Accepted answer
  1. Pramod Valavala 20,596 Reputation points Microsoft Employee
    2020-09-14T04:19:48.25+00:00

    Yes. That is a perfect approach for your scenario.

    And it is true that the bindings support only the SQL API. You could still use the CosmosDB SDK as-is in your function app without leveraging the browser if you required a different API though. While this is OK for input/output bindings, triggers would not work.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful