Azure Durable functions run only 10 minutes on premium plan

Bohdan B 0 Reputation points
2024-04-19T09:49:40.1266667+00:00

Hi there!

I have azure function that parses large docs.
I create orchestrator function that works fine, but it seems that it has limitation for 10 minutes.

    @FunctionName("RetryOrchestration")
    public HttpResponseMessage startOrchestration(
            @HttpTrigger(name = "request",
                    methods = {HttpMethod.POST},
                    authLevel = AuthorizationLevel.ANONYMOUS,
                    route = "retry/{name}") HttpRequestMessage<Optional<JsonObject>> request,
            @BindingName("name") String uid,
            @DurableClientInput(name = "durableContext") DurableClientContext durableContext,
            final ExecutionContext context) {
        context.getLogger().info("Java HTTP trigger processed a request.");
        var client = durableContext.getClient();
        var instanceId = client.scheduleNewOrchestrationInstance("RetryOperation", uid);
        context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId);
        return durableContext.createCheckStatusResponse(request, instanceId);
    }

    /**
     * This is the orchestrator function, which can schedule activity functions, create durable timers,
     * or wait for external events in a way that's completely fault-tolerant.
     */
    @FunctionName("RetryOperation")
    public void retryParseOrchestrator(
            @DurableOrchestrationTrigger(name = "taskOrchestrationContext") TaskOrchestrationContext ctx) {
        var input = ctx.getInput(String.class);
        var retryOption = new RetryPolicy(1, Duration.ofHours(1));
        TaskOptions options = new TaskOptions(retryOption);
        ctx.callActivity("Retry", input, options, String.class).await();
    }

    /**
     * This is the activity function that gets invoked by the orchestrator function.
     */
    @FunctionName("Retry")
    public void retry(@DurableActivityTrigger(name = "name") String name, final ExecutionContext context) {
        context.getLogger().info("Retry: " + name);
        parser.parse(name);
    }

When I run this code locally it runs without issues.
In the app insights I don't see any exceptions too.

So, I assume the issue is not caused by my code.
The strange stuff that I found from logs that it runs every ~ 10 mins.
User's image

My host.json is pretty straightforward

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  },
  "extensions": {
    "extensions": {
      "blobs": {
        "maxDegreeOfParallelism": 3
      }
    }
  },
  "functionTimeout": "00:30:00"
}

What may cause such strange behaviour? functionTimeout is set to 30 mins so it seems it does not apply to durable functions (???)

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,284 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshu katara 4,905 Reputation points
    2024-04-19T10:19:56.07+00:00

    Hi, Welcome to MS Q&A

    It seems like you're encountering issues with the execution time limit of your Durable Functions orchestrator. The functionTimeout setting in your host.json applies to regular Azure Functions, but Durable Functions have their own timeout settings.

    In Durable Functions, there are two types of timeouts to consider:

    Orchestrator Timeout: This is the maximum duration for which an orchestrator function can run before it's automatically terminated. By default, this timeout is set to 10 minutes. To change this timeout, you need to set the functionTimeout property specifically for the orchestrator function in your host.json file.

    Activity Timeout: This is the maximum duration for which an activity function can run before it's automatically terminated. If an activity function exceeds this timeout, the Durable Functions runtime will automatically retry the activity. You can configure this timeout in the orchestrator function when you call the activity, using the TaskOptions parameter.

    To increase the orchestrator timeout, you can modify your host.json file as follows:

    {
      "version": "2.0",
      "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.*, 5.0.0)"
      },
      "extensions": {
        "durableTask": {
          "hubName": "YourDurableFunctionsHubName",
          "orchestration": {
            "orchestrationTimeout": "00:30:00" // 30 minutes
          }
        }
      },
      "functionTimeout": "00:30:00"
    }
    
    

    Replace "YourDurableFunctionsHubName" with the name of your Durable Functions hub

    Please find doc for ref --> https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json

    Please check and kindly accept if it helps , Thanks!