I've got an Azure function unziping archives on a consumption plan. Some of them happens to take more than 10min to unzip and can timeout. I'm thinking of having a separate app service plan where I would reroute the extraction when timing out on consumption plan.
How would you do that? a timer in the function? a catch timeout exception? Do you have a better suggestion?
Thanks
For those interested I ended adding my own timeout (few seconds earlier than Azure one) to the extract function, then rerouting to another queue handled by a service app plan than don't timeout.
Code :
using (var timeoutCts = new CancellationTokenSource())
{
try
{
// task completed within timeout
timeoutCts.CancelAfter(590000);
var counter = await ExtractArchiveAsync(archiveFullName, myBlob, timeoutCts.Token);
log.Info($"Extracted : { counter.GetCurrentCount() }");
}
catch (OperationCanceledException)
{
// timeout logic
log.Info($"Function timedout, redirected to long queue");
var queue = StorageService.GetCloudQueueReference("ArchiveToExtractQueueTimedOut");
await queue.AddMessageAsync(new CloudQueueMessage(archiveFullName));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With