Problems with flex consumption function
I have a flex consumption function hosting a queue trigger function.
The function was deployed via azure cli using func azure functionapp publish <nnn>
and the hosts.json file:
{
"functionTimeout": "00:45:00",
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
},
"extensions": {
"queues": {
"batchSize": 1,
"messageEncoding": "none"
}
}
}
The function handler itself:
[Timeout("00:45:00")]
[Function(nameof(PdfConversionTrigger))]
public async Task Run([QueueTrigger("pdfcreation", Connection = "QueueConnectionString")] QueueMessage message)
{
//Message received. We need to do something with it...
QueuePdfDTO? queueMessage = JsonConvert.DeserializeObject<QueuePdfDTO>(message.MessageText);
if (queueMessage is null) return;
//Begin processing the PDF...
await CreatePDF(queueMessage);
}
When running a short job (a few seconds), it works correctly: it takes an item off the queue, performs the required processing, and exits.
When running a longer job (say 60 - 120 sec), it removes the item from the queue, performs the processing, and exits. However, it then repeats the processing for the queue item every ten minutes until the message is dequeued. I can see this happening as the file produced by the CreatePDF
method is produced five times, with time stamps ten minutes apart. The message is then added to the poison queue.
With longer jobs, which take more than ten minutes to process, the function runs for ten minutes, and then appears to just restart (usage is constant and high for ten minutes, drops to zero, and then repeats a total of five times). The message is then added to the poison queue.
Please help, it's not cost effective to a) process jobs five times, and b) I can't run the longer jobs at all. All of this worked fine on a consumption plan with the exception of the jobs that required more than ten minutes to complete.
The long job will run to completion if running the function locally.