I'm working with Azure Functions 2.0 and trying to send a collection of messages to Azure Service Bus Topic. Currently I'm using IAsyncCollector<T>
as output binding :
[FunctionName("MyFunction")]
public static async Task MyFunction([ServiceBus(MyTopicName, EntityType.Topic, Connection = ServiceBusConnection) outTopic])
{
var messages = await GetMessages();
foreach(var message in messages)
{
await outTopic.AddAsync(message);
}
}
Such approach is pretty convenient (declarative code, no boilterplate) but brings one significant issue: for large number of messages the performance is unacceptable. Is there any other recommended way to work with large batches that need to be sent to Azure Service Bus ?