I'm new to Azure Functions and trying to do a new project. I've run into some issues when my function takes too long to process the data. I'm using a BlobTrigger and every time someone uploads a new blob I need the data in the blob to analyze some things using other Microsoft Services.
Here is the code for my Azure Function:
[StorageAccount("BlobConnectionString")]
public class AnalyzeAzureBlob
{
private readonly IAnalyzeResult analyzeResult;
public AnalyzeAzureBlob(IAnalyzeResult analyzeResult)
{
this.analyzeResult = analyzeResult;
}
[FunctionName("AnalyzeAzureBlob")]
public void Run(
[BlobTrigger("samples-analyze/{name}")]Stream inputBlob,
[Blob("analyzed/{name}", FileAccess.Write)] Stream outputBlob,
string name,
ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {inputBlob.Length} Bytes");
try
{
this.analyzeResult.AnalyzeData(inputBlob, outputBlob);
log.LogInformation("The file has been analyzed");
}
catch (Exception ex)
{
log.LogError("The analyze failed", ex);
Console.WriteLine(ex.ToString());
}
}
}
The function runs as it should but sometimes the timeout is reached and it fails if the blob contains a large amount of data. How can I avoid timeouts and wait for the whole process to complete using Azure Functions?
Note: I've read about Azure Durable Functions but have a hard time understanding how to implement them and use them in my code.