Trigger Azure Functions using webhooks in Azure IoT Central

This topic applies to builders and administrators.

Note

You're currently viewing the original IoT Central documentation. To view the updated preview features documentation go to What is Azure IoT Central (preview features)?.

Use Azure Functions to run serverless code on the webhook output from IoT Central rules. You don't have to provision a VM or publish a web app to use Azure Functions, but instead you can run this code serverless. Use Azure Functions to transform the webhook payload before sending it to its final destination such as a SQL database or Event Grid.

Prerequisites

If you don't have an Azure subscription, create a free account before you begin.

How to connect Azure Functions

  1. Create a new function app in the Azure portal.

    Create a new function app in the Azure portal

  2. Expand your function app and select the + button next to Functions. If this function is the first one in your function app, select In portal as development environment and select Continue.

    Choose custom function in Function app

  3. Choose Webhook + API template and select Create. This topic uses .NET based Azure function.

    Select generic webhook trigger

  4. In your new function, select </> Get function URL, then copy and save the value. You use this value to configure the webhook.

    Get the URL of the function

  5. In IoT Central, navigate to the rule that you want to connect to your function app.

  6. Add a webhook action. Enter a Display name and paste in the function URL you copied earlier into Callback URL.

    Enter the function URL into the callback URL field

  7. Save the rule. Now when the rule is triggered, the webhook invokes the function app to run. In your function app, you can select Monitor to see the function's invocation history. You can use App Insights or the classic view to look at the history.

    Monitor the invocation history of the function

For more information, visit the Azure Functions article about creating a function triggered by a generic webhook.

Next steps

Now that you have learned how to set up and use webhooks, the suggested next step is to explore building workflows in Microsoft Flow.