in scenarios/aca-internal/bicep/sample-apps/jobs/src/aca-jobs/SBHelper.cs [36:58]
public static async Task SendNumberBatchAsync(this ServiceBusSender sender, ConfigurationOptions configuration,
ILogger logger, CancellationToken stoppingToken)
{
var batchMessage = await sender.CreateMessageBatchAsync(stoppingToken);
for (int i = 0; i < configuration.MessageCount; i++)
{
batchMessage.TryAddMessage(
new ServiceBusMessage($"{new Random().Next(configuration.MinNumber, configuration.MaxNumber)}"));
}
try
{
await sender.SendMessagesAsync(batchMessage, stoppingToken);
logger.LogInformation("Sent a batch of {Count} messages to the {Name} queue",
configuration.MessageCount, configuration.InputQueueName);
}
catch (Exception e)
{
logger.LogError("An error occurred while sending a batch message to the {Name} queue: {Error}",
configuration.InputQueueName, e.Message);
}
}