Search code examples
azurecloudiotazure-iot-hub

Azure IoT Hub - IoT Hub Trigger does not execute when route is enabled


I am trying to save JSON files sent to IoT Hub to a cosmos DB using a function that's triggered by IoT Hub. I am also trying to save the same files to a blob for long term storage.

So far the function and route work well independently, but they are not working at the same time (when route is enabled, the function is not triggered. The function only triggers when the route is not enabled.)

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling#other-limits

Limitation of F1 Free tier IoT Hub

I read on the IoT Hub quotas and throttling documentation that the Free tier can only perform one job at the same time. I am not sure if this would be the limitation holding me back, or if its faulty configuration on my side.

A possible solution I was thinking of could be to route traffic to a bus queue and make the function trigger from it instead.

Any help is much appreciated,

Thanks!


Solution

  • Messages that are routed won't automatically go to the default endpoint, hence your trigger will not fire anymore.

    There is a note in the "Message Routing" page of IoTHub's Azure Portal that explains it:

    "Create an endpoint, and then add a route (you can add up to 100 routes from each IoT hub). Since routing is based on a matching query, a message can be sent to multiple endpoints. Messages that don’t match a query are automatically sent to messages/events if you’ve enabled the fallback route. When you create new endpoints and routes, messages stop flowing to the built-in endpoint unless you create a separate route and direct them there. If no routes to the built-in endpoint exist, enabling a fallback route will direct any messages that don't match a route query to that endpoint."

    So if you want all messages to always get routed to the default endpoint just add a separate route for that.