Azure IoT Hub - IoTHubTrigger Azure function doesn't execute if a route is set up on the IoT Hub - azure

I have an IoTHubTrigger Azure function that processes the events from the IoT Hub.
It works as expected until I add a new Route in "Message routing" setting of the IoT Hub to send events to another event hub. In which case, the events successfully get routed to the event hub but don't hit the IoTHubTrigger Azure function anymore. Worth mentioning that the only options I have as endpoints to for route are Event Hubs, Service Bus Queue, Service Bus Topic and Storage.
Is there a way for me to have it route to both, the azure function and the event hub?

The following route will forward all telemetry messages to the default endpoint such as a built-in iot hub endpoint events:

Related

Simulated device with Azure Function on IoT Hub is not able to trigger

Currently I have simulated device that receives message from IoT Hub and processes it and after it is done, device sends message to IoT Hub. The device is working but it is running as .exe file on computer and Im trying to transform it and upload on Azure as function so I can avoid it not working when computer turns off or freezes while Im not around it.
I wanted to make it function triggered by events on IoT Hub but Im facing problem. Currently the function that sends message, sends it directly to device on IoTHub(my device) but in case like this, message is not "displayed" on IoT Hub so Im unable to use it as trigger. I'm unable to change function that sends message to device. Are there any options how to catch those messages on IoTHub or possibility to trigger it any other way?
There is no direct way to send messages from Azure function to Azure IoT Hub. You can probably utilize Device event Azure IoT Hub Rest API end point from the Azure Function and send the message to the Azure IoT Hub. Here is the request you can make to send the message to Azure IoT Hub.
POST https://fully-qualified-iothubname.azure-devices.net/devices/{id}/messages/events?api-version=2020-03-13
Please find the following reference to all the Supported bindings for Azure Functions runtime
You can trigger the Azure Function by using the IoT Hub trigger. Refer the following resource that runs you through the steps needed to set up the Azure IoT Hub trigger for Azure Functions

send events from Azure Service Bus Topic to Event Hub

I want to send an event that is sent to Azure Service Bus topic to an event hub. Is this possible?
Details:
I am working with a different team in my company that receives third party events (via webhook) to Azure Service Bus topic and this is further used in different application.
My team wants to now listen/subscribe to this topic using our existing event hub and using azure capture store these events to a storage account.
I did the following:
I created a subscription to their topic in their Azure Service Bus.
I created an event hub in my Event hub namespace.
I am not sure, how to now connect the azure service bus topic subscription to send those events to my event hub.
Thanks for your time.
Service bus operates with the receivers having to pull messages from it. This is opposite to Eventgrid which pushes the events to its subscribers. Eventhub does not pull messages from the source, we need to push messages into it. So you cannot achieve your requirement without an extra component between Service Bus and Eventhub.
One of the possible components would be a service bus topic triggered azure function LINK which writes into the eventhub using output binding LINK or the SDK LINK.
You will need to choose your service plan carefully depending on the volume of messages expected but usually Consumption plan will suit this purpose.

How to connect IoT hub to Kafka enabled event hub?

If IoT hub can have built in service endpoints for Event hub service then can it send all its messages to Kafka enabled Event hub, if yes how?
Simple link of documentation would also be helpful.
You can route device-to-cloud messages sent to your IoT hub to one or more endpoints by configuring routes - in addition to the built-in endpoint, you can route messages to Event Hubs, Service Bus, or blob storage. To get started, take a look at: https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-d2c. There's also a routing tutorial you can follow: https://learn.microsoft.com/azure/iot-hub/tutorial-routing

Trigger azure functions based on deviceids

I have two devices registered in IoT Hub. say device1 and device2. I have two azure functions say azurefunction1 and azurefunction2.
When a message is sent to Iot Hub with device1 I want azurefunction1 to get triggered but not azurefunction2.
Similarly When a message is sent to Iot Hub with device2 I want azurefunction2 to get triggered but not azurefunction1.
I tried using consumer groups but both azure functions are getting triggered.
Any help appreciated.
This is not directly possible. Events from both devices go to the same Event Hub, and Event Hub is the level of granularity for Functions trigger.
Consumer groups are for independent consumers, which both will get all events.
I would suggest you having a single Function to receive events from all devices. This Function could then route the request based on Device ID to other Functions if needed, e.g. via HTTP calls or via separate Storage Queues.
Another option is to use IoT Hub routing. You can route events to different IoT Hub endpoints based in the deviceid. You can then have azurefunction1 connected to the endpoint for device1, and azurefunction2 connected to the endpoint for device2.
The Routing Messages tutorial describes how to configure and use routing.

Azure Function App and IoT Hub Event hub

I have a Azure Function App which is bound as a trigger to Azure IoT Hub Event Hub.
As soon as any event is received by IoT Hub it triggers the Function App function and the message is received inside the Function App.
I want to re-raise the triggers for old events and want them on Function App right from the beginning. How can I refire the IoT Hub events so that the Function App can receive them from the beginning?
Thanks
You may create another consumer group for your EventHub and configure your Function's function.json to listen to that consumer group. This will allow your Function to read messages from the very beginning.

Resources