If I inject an IQueueClient I can send to that queue without relying on the old in-process way of doing it with IAsyncCollector
.net6 to .net8 isolated process Service Bus IAsyncCollector replacement
To send a message to a queue via a binding I previously used in .net6:
[ServiceBus("thequeue", Connection = "ServiceBusConnection", EntityType = ServiceBusEntityType.Queue)] IAsyncCollector<ServiceBusMessage> outputQueue
When trying to do the same in net8:
[Function(nameof(QueueHandler))] [ServiceBusOutput("%TestOutputQueueName%", Connection = "ServiceBusConnection")] public async Task<ServiceBusMessage> Run([ServiceBusTrigger("%TestInputQueueName%", Connection = "ServiceBusConnection", AutoCompleteMessages = false)] ServiceBusReceivedMessage message, ServiceBusReceiver receiver, ServiceBusMessageActions serviceBusMessageActions)
var outputMessage = new ServiceBusMessage { Body = BinaryData.FromString("testcontent"), MessageId = message.MessageId }; outputMessage.ApplicationProperties["RetryCount"] = "111"; IEnumerable<ServiceBusMessage> outputMessages = [outputMessage]; return outputMessage;
The received message on the queue always has an empty Body but the RetryCount property is correct. Sending a primitive type from the function is of no use as I need to set properties on the message itself. I need to complete and then retry a failed message. The complete works fine. The sent message always has an empty body.
Is there a way to reproduce the net6 behaviour of IAsyncCollector?