0
votes

Azure function cannot start when I have a auto forward queue:

Function XXX Error: The listener for function 'FunctionXXX' was unable to start. Microsoft.ServiceBus: Cannot create a message receiver on an entity with auto-forwarding enabled.

            // Code to create the queue:
            var manager = NamespaceManager.CreateFromConnectionString("ConnectionString");
            manager.CreateQueue(new QueueDescription("myqueue_done")
            {
                RequiresSession = false
            });
            manager.CreateQueue(new QueueDescription("myqueue")
            {
                ForwardTo = "myqueue_done",
                RequiresSession = false
            });

And here is my azure function:

    [FunctionName("FunctionXXX")]
    public static void Run([ServiceBusTrigger("myqueue", Connection = "AzureSbConnectionString")]string myQueueItem, string messageId, string CorrelationId, TraceWriter log)
    {          

        log.Info($"Message id={messageId}, CorrelationId={CorrelationId}, was processed: {myQueueItem}");
    }

Is it really a limitation? Is there a better way to move processed messages inside this azure function sandbox method?

Tks!

1
I think the better way to do what I wanted is follow this sample, when you can create another message with a out parameter github.com/Azure/azure-webjobs-sdk-samples/blob/master/… - rd_rscan

1 Answers

1
votes

This is not a limitation of Functions, it's the way Service Bus works.

When auto-forwarding is enabled, Service Bus automatically removes messages that are placed in the first queue or subscription (source) and puts them in the second queue or topic (destination).

If your messages are forwarded to another queue and removed from the original queue, it doesn't really make sense to create a manual receiver from the same queue.