Search code examples
azure-functionsazure-blob-storage

Azure Blob Trigger - Processing Timeout


I'm looking to use a Blob Trigger for a long running processing of a file.

I'm aware there a processing timeouts durations for and have seen 5 minutes for Http trigger on consumption plan but can't find any documentation if there timeouts imposed for Blob triggers.


Solution

  • You can use functionTimeout attribute to schedule the timeout for Blob trigger Azure function.

    Refer MSDOC to know more about functionTimeout.

    enter image description here

    • In Consumption Plan, Default Timeout is 5 Minuted and Maximum Timeout is 10 Minutes.

    • For long running process that is more than 10 minutes, you can use Premium or App Service Plans.

    • Set the functionTimeout in host.json as shown below:

    {
    "functionTimeout":"01:00:00"
    }
    

    I have created a Blob Trigger Azure function:

    [FunctionName("Function")]
    public void Run([BlobTrigger("myqueue-items/{name}", Connection = "demo")]Stream myBlob, string name, ILogger log)
    {
        log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        System.Threading.Thread.Sleep(30000);
    }
    
    • I'm let the function will sleep for 30 seconds by adding System.Threading.Thread.Sleep(30000); in the function code.

    host.json:

    I have scheduled the functionTimeout for 20 seconds.

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "samplingSettings": {
            "isEnabled": true,
            "excludedTypes": "Request"
          },
          "enableLiveMetricsFilters": true
        }
      },
      "functionTimeout": "00:00:20"
    }
    

    I can see the function getting time out after 20 seconds.

    enter image description here

    • You can schedule the functionTimeout according to your requirement.

    References:

    https://github.com/Azure/Azure-Functions/issues/1900