title: How to use an Azure Function Binding to send a scheduled Service Bus Queue message?
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>The <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus" rel="nofollow noreferrer">binding documentation</a> doesn't mention scheduled messages.  However, interestingly enough <a href="https://github.com/Azure/Azure-Functions/issues/169" rel="nofollow noreferrer">this comment</a> has been made a few times on the Functions github issues repository:</p>
  
  <blockquote>
    <p>At least with C# &amp; 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:</p>
    
    <p><code>outgoingMessage.ScheduledEnqueueTimeUtc =
    DateTimeOffset.UtcNow.AddSeconds(10)</code></p>
  </blockquote>
  
  <p>Anyway, here's my current code that is working fine for immediately delivering a message:</p>
  
  <p><strong>function.json</strong></p>
  
  <pre><code>{
    "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"
      }
    ]
  }
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>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();
  
  };
  </code></pre>