As per the documentation on ServiceBus output bindings:
For creating multiple messages in a C# function, you can use ICollector<T>
or IAsyncCollector<T>
. A message is created when you call the Add method.
Here is a simple example of using ICollector (also directly from the docs):
public static void Run(TimerInfo myTimer, TraceWriter log, ICollector<string> outputSbQueue)
{
string message = $"Service Bus queue message created at: {DateTime.Now}";
log.Info(message);
outputSbQueue.Add("1 " + message);
outputSbQueue.Add("2 " + message);
}
I personally find that all of the supported input/output bindings are well documented and examples are readily available at the link I've shown here. Just pick the appropriate binding you're working with (if it's something other than Service Bus)