Are Service-Bus-Triggered functions triggered only when items are added to a queue/subscription?

NSou 21 Reputation points
2021-05-20T19:25:39.387+00:00

If there are items in our subscription when our function app starts, we've noticed that the function doesn't trigger until a new item is added. Is this expected behavior and is there a way for the function to keep triggering until all items have been processed? Thanks.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
700 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-05-21T04:28:08.833+00:00

    @NSou If there are any active messages on the queue/subscription then the service bus function should be triggered continuously until and unless all the messages are not consumed from the service bus entity (queue/subscription). I have tested the same at my end (queue having 4000 existing messages) and couldn't observe the same behaviour as you have mentioned. The function was continuously getting triggered until and unless all messages were not consumed.
    Tested using function v3 C# code.

    [FunctionName("Function1")]  
            public static void Run([ServiceBusTrigger("gittest", Connection = "ServiceBusConnection")]string myQueueItem, ILogger log)  
            {  
                log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");  
            }  
    

    The output that shows that the function was continuously triggering :
    98511-image.png

    Can you share the code snippet along with the other configuration.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.