Azure WebJob QueueTrigger How to DeleteMessage after receiving?

I have one webjob on azure, with QueueTrigger. Long work (more than 30 minutes)

public async static Task ProcessQueueMessageAsync([QueueTrigger(QUEUENAME)] string iJobId) { //doing my long job } 

My problem is how to delete the message in the queue after starting. The message becomes invisible until a period of time appears (30 seconds by default). Much less than my duration. Therefore, I believe that I need to delete the message at the beginning of the trigger method. I find how to do this when you execute a loop using the GetMessage() method, rather than starting it. But how to do this with a trigger, because I don't have a message object to run .DeleteMessage() ?

+5
source share
1 answer

Answered by Michael Kerd on MSDN Forums and quoted here:

The SDK should already be able to handle this. As you said, the message will be leased (or made invisible) within 30 seconds by default. If the work takes longer, the rental will be resumed. The message will not be available for another instance of the function if the host does not work or the function throws an exception. When the function succeeds, the message is deleted by the SDK. Therefore, you do not need to write any special code for this script.

+3
source

All Articles