0

I need to process a task queue and I wonder if Azure Queue will work for my case. Task execution implies querying a rate-limited API and for that reason I want polling to happen every X seconds (can be slower, but must not be faster than that). Azure Function app would consume queue messages with concurrency of 1.

In the host.json settings maxPollingInterval can be configured. For the minimum interval it says

Minimum is 00:00:00.100 (100 ms) and increments up to 00:01:00 (1 min)

Is there any way to force the required delay between polls?

Max Ivanov
  • 5,695
  • 38
  • 52

1 Answers1

3

The azure queue may not meet your need. Here is the polling algorithm:

  • When a message is found, the runtime waits two seconds and then checks for another message
  • When no message is found, it waits about four seconds before trying again.
  • After subsequent failed attempts to get a queue message, the wait time continues to increase until it reaches the maximum wait time(maxPollingInterval), which defaults to one minute.

So it does not poll the queue every X seconds.

You may consider using timer trigger function which can be specified to run at every X seconds; and inside the function, you can write your logic to call the api.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • 1
    I'm accepting this answer since it's what I'll probably do. Had some issues with running a timer function locally on Mac, but now it's [resolved](https://stackoverflow.com/a/64492604/2579733). There may still be an Azure Queue involved for passing tasks to the timer func. For the whole picture there seems to be an alternative solution of deploying a queue-triggered function with `functionAppScaleLimit=1` setting combined with a batch limit of 1 which will wait the required X seconds before exiting. Timer trigger is simpler though and works for my needs at the moment. – Max Ivanov Oct 23 '20 at 08:33