I'm writing a JavaScript Azure Function with a Queue Trigger. When I get a message from the queue, if I'm ready to process it I do so. If I'm not, I want to put the message back in the queue with a delay of 15 minutes, so that I won't process it again for at least 15 minutes.
I've found a couple of examples of how to do this using a function written in C#
Implementing Delay Queue using one or more standard FIFO Queues
But I haven't figured out how to do something similar in Javascript.
I looked through the Azure Storage Queue SDK for NodeJS and tried the below code with the expectation that the message would be invisible for 60 seconds:
const {QueueServiceClient} = require("@azure/storage-queue");
module.exports = async function (context, req) {
const STORAGE_CONNECTION_STRING = process.env["AzureWebJobsStorage"];
const queueServiceClient = QueueServiceClient.fromConnectionString(STORAGE_CONNECTION_STRING);
const queueClient = queueServiceClient.getQueueClient('queue-name');
const data = 'test message';
const buff = new Buffer(data);
const base64data = buff.toString('base64');
queueClient.sendMessage(base64data, {visibilitytimeout: 60})
};
However, the messages are still enqueued/dequeued immediately.
How can I enqueue a message so it won't be processed for 15 minutes?