Is an Azure Function on a Consumption plan billed for time spent waiting for Thread.Sleep()?

Viewed 464

I am writing an Azure Durable Function to process various bulk operations. Te code can get 1000 operations in a file and it's breaking those down to call the same activity function 1000 times.

The problem is that this can flood an API that the activity function uses up to the point that our activity function gets a 429 - Too Many Requests from the API. We are thinking of reading the Retry-After header offered and putting the thread to sleep for that period of time.

In this case, we're wondering if Azure will bill us for the seconds we're waiting for. Also, would this time count towards the timeout for the Azure function?

1 Answers

First, use the Durable Function Timers, not Thread.Sleep(). Then, the following applies:

If your function app uses the Consumption plan, you will still be billed for any time and memory consumed by the abandoned activity function. By default, functions running in the Consumption plan have a timeout of five minutes. If this limit is exceeded, the Azure Functions host is recycled to stop all execution and prevent a runaway billing situation. The function timeout is configurable.

https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-timers

Related