Logic apps Service bus connector not honoring Maximum message count
You might come across a scenario where you dont receive the batch of messages configured under maximum message count property in your logic app service bus connector setting.
In this example, i have configured the maximum message count as 20 but still I recieved only 1 or 2 messages every time even when i had a lot of messages in Service bus.
The reason being my testqueue was partition enabled.
Once i use the non partition queue, i was able to receive the configured number of messages in a single batch.
The message count property specifies the maximum number of messages that can be returned. The actual number of messages returned can be anywhere between 0 to message count. The documentation of Service bus partitioning https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-partitioning also mentions this:
Browse/Peek messages: PeekBatch does not always return the number of messages specified in the MessageCount property. There are two common reasons for this. One reason is that the aggregated size of the collection of messages exceeds the maximum size of 256KB. Another reason is that if the queue or topic has the EnablePartitioning property set to true, a partition may not have enough messages to complete the requested number of messages.