'Send batch messages to Service Bus topic from Azure function
In Azure function I am using service bus trigger to read message from queue and send it to a topic after processing the message. I am using return output binding option to send message. This works as expected.
[FunctionName("Function1")]
[return: ServiceBus("mytopic", EntityType.Topic, Connection = "topicConnection")]
public static async Task<Message> Run([ServiceBusTrigger("myqueue", Connection = "queueconnection")] Message myQueueItem, MessageReceiver messageReceiver, ILogger log)
But now I am planning to read messages from a queue as batch. So to achieve this I am using Message[] myQueueItem which works.
[FunctionName("Function1")]
[return: ServiceBus("mytopic", EntityType.Topic, Connection = "topicConnection")]
public static async Task<Message> Run([ServiceBusTrigger("myqueue", Connection = "queueconnection")] Message[] myQueueItem, MessageReceiver messageReceiver, ILogger log)
But I am not finding any option to send messages to topic as batch or array of messages using the return option. One of the alternative option is to use TopicClient object and call SendBatchAsync. I want to understand if I can do this using the return option easily.
Solution 1:[1]
When sending multiple messages with Functions, depending on the SDK you're using the implementation is different. For In-Process SDK you use a collector. For Isolated Worker SDK you use a custom returned type. I have a blog post that goes into details for both SDKs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sean Feldman |
