shyam_baidya
shyam_baidya

Reputation: 119

How to set Infinite Timeout for Azure Function app v2.0

I have a very long running process which is hosted using Azure Function App (though it's not recommended for long running processes) targeting v2.0. Earlier it was targeting v1.0 runtime so I didn't face any function timeout issue.

But now after updating the runtime to target v2.0, I am not able to find any way to set the function timeout to Infinite as it was in case of v1.0.

Can someone please help me out on this ?

Upvotes: 5

Views: 8752

Answers (3)

Pawel Maga
Pawel Maga

Reputation: 5807

One way of doing it is to implement Eternal orchestrations from Durable Functions. It allows you to implement an infinite loop with dynamic intervals. Of course, you need to slightly modify your code by adding support for the stop/start function at any time (you must pass the state between calls).

[FunctionName("Long_Running_Process")]
public static async Task Run(
    [OrchestrationTrigger] DurableOrchestrationContext context)
{
    var initialState = context.GetInput<object>();
    var state = await context.CallActivityAsync("Run_Long_Running_Process", initialState);

    if (state == ???) // stop execution when long running process is completed
    {
        return;
    }

    context.ContinueAsNew(state);
}

Upvotes: 1

Rohit Saigal
Rohit Saigal

Reputation: 9684

From your comments it looks like breaking up into smaller functions or using something other than functions isn't an option for you currently. In such case, AFAIK you can still do it with v2.0 as long as you're ready to use "App Service Plan".

The max limit of 10 minutes only applies to "Consumption Plan".

enter image description here

In fact, documentation explicitly suggests that if you have functions that run continuously or near continuously then App Service Plan can be more cost-effective as well.

You can use the "Always On" setting. Read about it on Microsoft Docs here.

Azure Functions scale and hosting

enter image description here

Also, documentation clearly states that default value for timeout with App Service plan is 30 minutes, but it can be set to unlimited manually.

Changes in features and functionality

enter image description here

UPDATE

From our discussion in comments, as null value isn't working for you like it did in version 1.x, please try taking out the "functionTimeout" setting completely.

I came across 2 different SO posts mentioning something similar and the Microsoft documentation text also says there is no real limit. Here are the links to SO posts I came across:

Upvotes: 10

E McG
E McG

Reputation: 289

You cannot set an Azure Function App timeout to infinite. I believe the longest any azure function app will consistently run is 10 minuets. As you stated Azure functions are not meant for long running processes. You may need find a new solution for your app, especially if you will need to scale up the app at all in the future.

Upvotes: 0

Related Questions