Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Function and storage queue, what to do if function fails

I'm working out a scenario where a post a message to an Azure Storage Queue. For testing purposes I've developed a console app, where I get the message and I'm able to update it with a try count, and when the logic is done, I delete the message.

Now I'm trying to port my code to an Azure Function. One thing that seems to be very different is, when the Azure Function is called, the message is deleted from the queue.

I find it hard to find any documentation on this specific subject and I feel I'm missing something with regard to the concept of combining these two.

My questions:

  1. Am I right, that when you trigger a function on a new queue item, the function takes the message and deletes it from the queue, even if the function fails?
  2. If 1 is correct, how do you make sure that the message is retried and posted to a dead queue for later processing?
like image 446
Oak3 Avatar asked Oct 12 '16 19:10

Oak3


People also ask

How do I troubleshoot Azure function?

Navigate to your function app in the Azure portal. Select Diagnose and solve problems to open Azure Functions diagnostics. Choose a category that best describes the issue of your function app by using the keywords in the homepage tile. You can also type a keyword that best describes your issue in the search bar.

How do I fix runtime unreachable Azure?

Search for your storage account in the Azure portal to see whether it still exists. If it has been deleted, re-create the storage account and replace your storage connection strings. Your function code is lost, and you need to redeploy it.

What is the service function of Azure queue storage?

Azure Queue storage is a service for storing large numbers of messages that can be accessed from anywhere in the world via authenticated calls using HTTP or HTTPS. A single queue message can be up to 64 KB in size, and a queue can contain millions of messages, up to the total capacity limit of a storage account.


1 Answers

The runtime only deletes the queue message when your Function successfully processes it (i.e. no error has occurred). When the message is dequeued and passed to your function, it becomes invisible for a period of time (10 minutes). While your function is running this invisibility is maintained. If your function fails, the message is not deleted - it remains in the queue in an invisible state. After the visibilty timeout expires, the message will become visible in the queue again for reprocessing.

The details of how core WebJobs SDK queue processing works can be found here. On that page, see the section "How to handle poison messages" which addresses your question. Basically you'll get all the right behaviors for free - retry handling, poison message handling, etc. :)

like image 116
mathewc Avatar answered Oct 12 '22 11:10

mathewc