Function App with IotHub - synchronous events reading from multiple partitions

Viewed 14

I'm working on Function App (.NET) that reads events from IotHub(Azure). I have problem with parralel instances of app that cannot happen. I used

"eventProcessorOptions": {
        "maxBatchSize": 1,
        "prefetchCount": 10
      }

in host.json so that my app take one event at the time. Everyting works fine until I get message frome other device. Then IotHub (EventHub) write this event to second partition, and because this settings applies only to partition level - another instance od my Function App is made. Problem is that my app has CosmosDB as a memmory that must be updated after every event (run) so that with next one Function App could check what changed (like last state). I use Optimistic Concurrency to avoid this and it's ok when there are messages on two partitions. But I don't want to limit partitions on IotHub to just two and with more devices working and sending messages simultaneously there will be a lot of situation like that and I think that only Optimistic Concurrency wan't be enough to resolve them. It will also expand the time of app running. I hope it's clear to undertand :)

Do you know a way to read events from IotHub synchronous, one by one, chronologically from all partitions?

0 Answers
Related