0

I am using Microsoft IoT Central and use its rules to trigger actions.

One can choose a number of actions when the rule is triggered like email, Webhook, Logic Apps as well as Power Automate. I have tried using all of them without any issues. Now I trying to define a simple NodeJS Azure function that shall be run whenever the IoT Central Rule is triggered.

What I don't understand is how to set it up end-to-end using an Azure Function. One cannot choose any existing function from the IoT Central action on rule menu, but are instead pointed to creating a new function.

When I try that from within Azure there is not any "IoT Central" function template as there is for for example IoT Hub or HTTP Trigger.

So - how do I "connect" a new Azure function to be triggered from the IoT Central rule?

enter image description hereenter image description hereenter image description here

1 Answers1

0

Triggering an Azure Function from IoT Central is done by creating a Function with an HTTP trigger and using the Webhook action to trigger it.

setting up a webhook

The process is documented here

Update: I see in your screenshot that you are using an older version of IoT Central. In that version, Azure Functions is mentioned as a separate action, but in reality it was just using a webhook as well. Azure Functions as a separate action was removed in a later version when you select Webhook, it's mentioned as an option (as in the above screenshot).

Matthijs van der Veer
  • 3,865
  • 2
  • 12
  • 22
  • Thank you Matthijs! That is one way of doing it yes. But if that is the intended way, why have both Webhook and Azure Function in the selection of actions to choose from in the IoT Central rule? I assume selecting Azure Function option as different from the Webhook option. – Tobias Persson Aug 21 '20 at 09:54
  • I'm sorry, should have explained: The screenshot I took is from the current version of IoT Central. You seem to be using the legacy version, where Azure Functions is indeed mentioned as a separate trigger, but in reality it's just another webhook. In the current version Functions aren't mentioned separately anymore. Webhook is the intended way. I'll update my answer to include this. – Matthijs van der Veer Aug 21 '20 at 10:26
  • Aha! You are right, I just tend to think the legacy version is much simpler to understand. Thanks a lot for your swift reply, good stuff. – Tobias Persson Aug 21 '20 at 13:28
  • It definitely was, just less powerful. There are new options for ruling now too though. Could you mark the answer as accepted? – Matthijs van der Veer Aug 21 '20 at 14:13
  • Absolutely, how do I mark it as Accepted? And on the same topic as above - it is easy to setup an HTTP-triggered Azure function. I would however like to create as JSON message, based on the IoT Central Webhook output, to be placed on a Service Bus for further downstream handling. Do you know the best way to do that? A few seem to have run into difficulties since the HTTP trigger function is declared async and doesn't support outbound bindings. – Tobias Persson Aug 24 '20 at 01:58
  • [This](https://stackoverflow.com/help/someone-answers) page describes it best. As for your other question, I'm not aware of the async keyword being a problem in that scenario. You can create a new question for it and people will be on it! – Matthijs van der Veer Aug 24 '20 at 05:26