Skip to content

DevOps Yoz Connect the Iot function to Iot Hub, & automate it (powershell) Task #129

Yozelin edited this page Mar 10, 2020 · 1 revision

Step 1: IoT Hub First, we need to set up an IoT Hub and start sending messages to it. F

When I ran through this, I chose to use Node. I left the device simulation active on the machine, which kept pushing events to IoT Hub.

Step 2: Azure Functions triggered by IoT Hub Azure Functions has integration with IoT Hub out of the box, so it is very simple to get this up and running. Follow the steps below to get an Azure Function reacting to IoT Hub events:

  • Create a Function App
  • Once the Function is created, navigate to the “Create new function from template page”:
  • Select IoT Hub (Event Hub) and Javascript as the language
  • Azure Functions will create the connection with IoT Hub for you after selecting this template, so you just have to click on the "new" button and select the proper IoT Hub instance:
  • The Function created will be triggered by the IoT Hub events
  • modify the code on our Function to store the data on Cosmos DB using the output binding, and since the Function was created in Javascript, all we have to do is add the output to context.bindings

img-1

function code

Clone this wiki locally