I have a blob triggered function, in which a data is deserialized from a Json string and then the further process are done and save the data to db.
My blob trigger function max retry is set as 5. Means if the blob process fails it will retry for 5 times and then move the blob to poison blob.
If the deserialization is failed, then there is no need to retry it for 5 times. So, if the deserialzation exception is thrown I need to move the blob to poison blob without retry. Is there any way to handle this?
There is no built-in solution for such case afaik, but you can add an output binding to your poison queue and insert a message manually in the form described here:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob#trigger---poison-blobs
The queue message for poison blobs is a JSON object that contains the following properties:
FunctionId (in the format .Functions.)
BlobType ("BlockBlob" or "PageBlob")
ContainerName
BlobName
ETag (a blob version identifier, for example: "0x8D1DC6E70A277EF")
[FunctionName("blobtrigger")]
public static async Task Run(ILogger log, ExecutionContext executionContext,
[BlobTrigger("blobs/{name}")] Stream blob,
[Queue("webjobs-blobtrigger-poison")] CloudQueue poisonQueue)
{
try {
// do something
throw new JsonSerializationException();
}
catch (JsonSerializationException ex)
{
log.LogError(ex, ex.Message);
await poisonQueue.AddMessageAsync(new CloudQueueMessage()); // your message
}
}
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