1

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}");
}
Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
chiaDev
  • 389
  • 3
  • 17

1 Answers1

2

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.

Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
  • I see. But is there anyway we can customise the polling interval for servicebustrigger too? or it is a fixed mechanism? – chiaDev Aug 30 '21 at 08:29
  • See this answer https://stackoverflow.com/a/48899686/1163423 – Martin Brandl Aug 30 '21 at 08:56
  • I see. Am I correct in understanding that the servicebustrigger is controlled by Scaling Controller which internally does polling and hence I could only control the parameters like maxConcurrentCalls to control the "polling" rate? – chiaDev Aug 30 '21 at 09:57
  • I think yes. Here you see all global settings that you can configure for the Service Bus binding - and there is no polling configuration: https://learn.microsoft.com/azure/azure-functions/functions-bindings-service-bus?WT.mc_id=AZ-MVP-5003203#hostjson-settings . But if you have a look at the Table Queue Binding, there is a setting to configure the polling interval: https://learn.microsoft.com/azure/azure-functions/functions-bindings-storage-queue?WT.mc_id=AZ-MVP-5003203#hostjson-settings – Martin Brandl Aug 30 '21 at 10:48
  • 1
    @MartinBrandl, for clarification of the emitting SB events to the AEG: *case 1:* immediately. if the SB entity is empty AND a new message arrives, *case 2:* every two minutes, if the SB entity is not empty AND there is no active listener/receiver. – Roman Kiss Aug 30 '21 at 16:11
  • @MartinBrandl yes I have checked those 2 linked before this, thats how I figured out that Table Queue Binding uses polling. But didnt manage to find anything of that sort for Service Bus Binding – chiaDev Aug 31 '21 at 12:20