0
votes

I have a situation where a blob might fail to process the first time but might work on a subsequent execution.

The issue I am having is around monitoring true failures, at the moment the first failure will throw an exception, which is logged and alerted on but if the first retry completed successfully then there is nothing to do based on the earlier alert.

Is there a way to view the number of retries that have happened, so that I can only alert if it is no longer going to be retried?

2
Default is 5, try set maxDequeueCount to 1.docs.microsoft.com/en-us/azure/azure-functions/…. - George Chen
I want the retrying, I just only want to throw an exception when it fails on the 5th time basically. - blawford
Cant you just keep track of the number of retries in your method that is getting the blob file, then log and alert when it exceeds your threshold? - Patrick Goode
Each execution is triggered and runs independently, so I am looking for a way to persist how many attempts have been made on a blob. - blawford
the alternative way to BlobTrigger function is to use an Azure Event Grid with more reliable event delivery processing, retry policy and dead-lettering, see more details in the docs.microsoft.com/en-us/azure/event-grid/delivery-and-retry - Roman Kiss

2 Answers

1
votes

You can change your function handler to retrieve the message metadata, including the dequeue count.

Retrieving queue metadata from an Azure Storage Queue Trigger

[FunctionName("QueueTriggerMetadata")]
public static void Run([QueueTrigger("101functionsqueue", Connection = "AzureWebJobsStorage")]CloudQueueMessage myQueueItem, TraceWriter log)
{
    log.Info("101 Azure Function Demo - Retrieving Queue metadata");

    log.Info($"Queue ID: {myQueueItem.Id}");
    log.Info($"Queue Insertion Time: {myQueueItem.InsertionTime}");
    log.Info($"Queue Expiration Time: {myQueueItem.ExpirationTime}");
    log.Info($"Queue Payload: {myQueueItem.AsString}");

    log.Info($"Dequeue Count: {myQueueItem.DequeueCount }");
}

Having said that, you might still want to use the poison queue to handle failed messages like Mike suggests in his answer. It depends on your exact scenario.

0
votes

After a blob trigger function fails for the last time, Azure should write a message to a storage queue called webjobs-blobtrigger-poison. You can monitor this storage queue for new messages as a way to monitor actual failures after the retries have been exhausted.

See: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=csharp#poison-blobs