azureazure-functionsazureservicebusazure-servicebus-queuesazure-triggers

What is the underlying mechanism to receive message in Azure Function Service Bus Queue Triggered functions?


I understand that Azure Function - Azure Storage Queue triggered functions are triggered on a polling basis.

But cant seem to find how it work for Azure Service Bus queues. Does it also follow the polling approach or has a session with the Azure Service Bus queue client that gets triggered whenever a message is sent into the queue (something like an event-driven approach)?

Please refer to the following code:

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

Solution

  • The SerivceBusTrigger is also on a polling basis because of the underlying service architecture:

    Azure Service Bus characteristics:

    is a reliable asynchronous message delivery (enterprise messaging as a service) that requires polling

    Source.

    However, Azure Service Bus integrates with Azure Event Grid (Service Bus will send events to Azure EventGrid when there are new messages) so this would prevent you from polling - if you switch to Azure Event Grid Trigger instead.