I have an Azure Function written in node.js that is successfully sending a message to an Azure Service Bus Queue using an output binding.
How can I send a scheduled message into the same Queue still using the binding syntax? I'd rather do this without installing the node.js sdk if at all possible.
The binding documentation doesn't mention scheduled messages. However, interestingly enough this comment has been made a few times on the Functions github issues repository:
At least with C# & Node.js (and why not in F#) the Service Bus queue output already supports this e.g. if you create and put multiple messages e.g. to IAsyncCollector or create out BrokeredMessage. Within your outgoing message(s) you can control the scheduled enqueuing time:
outgoingMessage.ScheduledEnqueueTimeUtc = DateTimeOffset.UtcNow.AddSeconds(10)
Anyway, here's my current code that is working fine for immediately delivering a message:
function.json
{
"disabled": false,
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name" : "queueOutput",
"queueName" : "scheduler",
"connection" : "AZURE_SERVICEBUS_CONNECTION_STRING",
"type" : "serviceBus",
"direction" : "out"
}
]
}
index.js
module.exports = function (context, req) {
context.log('Scheduler function processed a request.');
context.bindings.queueOutput = req.body;
context.res = {
"status": 200,
"body": {
"message": "Successfully sent message to Queue"
}
};
context.done();
};