I have a TimerTrigger
Azure Function which triggers every one minute.
When it triggers I read a specific number of messages from my queue by this code:
cloudQueue.GetMessagesAsync(32);
And when I'm done with it I see the message gets visible in the queue again, although the function did NOT encounter any errors.
I've looked at these answers, but they all say if you have no errors in your function at runtime, messages should be removed from queue:
Azure Queue Storage triggered without removing message
Azure Function and storage queue, what to do if function fails
But my messages don't remove.
Here is my function code:
[FunctionName("MyFunctionName")]
public static async Task SchedulerFunction([TimerTrigger("0 */1 * * * *", RunOnStartup = false)]TimerInfo myTimer, [Queue("my-queue-name", Connection = "AzureWebJobsStorage")]CloudQueue cloudQueue)
{
var messages = await cloudQueue.GetMessagesAsync(32);
await ProcessSomethingOnMessagesWithoutAnyErrors(messages);
}
What I need is to remove the collected messages from the queue after I got them by cloudQueue.GetMessagesAsync(32);
and if It fails for 3 times, then move them into my-queue-name-poison
queue.
If I need to use any specific RetryPolicy
, don't hesitate to recommend it.