I am doing this using a database, a row lock update request, and a TransactionScope object.
In the Order table, create a column to control the status of the action you take in your WebJob. those. EmailSent.
In the QueueTrigger function, start the transaction, then execute the UPDATE query in the sales order using the ROWLOCK set, which sets EmailSent = 1 with WHERE EmailSent = 0. If the return value is from SqlCommand = 0, then exit the function. Another WebJob has already sent an email. Otherwise, send an email and call Complete () on the TransactionScope object if it was sent successfully.
This should provide the desired idempotency.
Hope this helps.
source share