The workaround I did was to create a bind to the same queue that triggers the function.
[FunctionName("FunctionsQueueTrigger")]
public static async Task Run(
[QueueTrigger("101functionsqueue")] string myQueueItem,
[Queue("101functionsqueue")] IAsyncCollector<string> myQueue)
In my case, I wanted to put the item back to the queue if a storage exception was thrown with the code 412 (Precondition Failed).
catch (StorageException ex)
{
if (ex.RequestInformation.HttpStatusCode == (int)System.Net.HttpStatusCode.PreconditionFailed) //412
{
log.LogWarning($"Putting item back to queue due to {ex.Message} error.");
await myQueue.AddAsync(myQueueItem);
}
}
In the end, the function removes the current item from the queue, but a new one with the same content is added.
It may be not the best solution but worked fine for me.