Azure Function doesn't trigger by IOT Hub

Pavel Livshits 10 Reputation points
2023-01-15T08:57:25.36+00:00

Hello,

I have an issues with triggering functions by events from iothub edge devices. I need to run two functions that would listen on Edge device events but triggered according to the some quarry.

For that purpose on the IOT hub side I have created 2 Event Hubs with full shared access policies, 2 endpoints and 2 routes without any routing queries so at the beginning that both functions will get all the events, later I'll do the filtering. On the function side both functions are configured to be triggered by their own set.

@EventHubTrigger(name = "message1", eventHubName = "event1", connection = "AzureIotHubEvent1", consumerGroup = "$Default", cardinality = Cardinality.MANY)

@EventHubTrigger(name = "message2", eventHubName = "event2", connection = "AzureIotHubEvent2", consumerGroup = "$Default", cardinality = Cardinality.MANY)

However, no matter what I do only one function is getting events and the other getting nothing. I have checked and rechecked the configuration but it's haven't found anything there. Moreover, both Event Hubs Instances are getting the all the events.

Any idea what might be the problem and how to debug it?

Thanks,

Pavel

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 17,866 Reputation points Moderator
    2023-01-16T16:45:36.58+00:00

    Hi @Pavel Livshits Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question.

    The publish/subscribe mechanism of Event Hubs is enabled through consumer groups. A consumer group is a view (state, position, or offset) of an entire event hub. Consumer groups enable multiple consuming applications to each have a separate view of the event stream, and to read the stream independently at their own pace and with their own offsets.

    Instead of using the $Default consumer group to process Events routed to the Event Hub, create two unique consumer groups, one for each end point. Provide the created consumer group name in the function consumerGroup attribute. You can create the consumer group through your Azure Portal under the Built-in endpoints of your IoT Hub. Please refer the below image

    consumer group

    I have also noticed that you are using a "cardinality" attribute in your EventHubTrigger function. I could not find a reference of this attribute in the official documentation of Event Hub Trigger I appreciate it if you can provide a reference of the resource where you have obtained this attribute from.

    Please let us know if information shared is useful. Reach out to us if you still face issues and we would be glad to assist you.


    • Kindly mark the answer as useful if the response is helpful so that it would benefit other community members facing the same issue. 
    • Original posters help the community find answers faster by identifying the correct answer. Here is how 
    • I highly appreciate your contribution to the community. 
    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.