title: mscorlib: TypeError: context.res is not a function
body: <p>I am writing a a NodeJS function for Azure Functions. However, when trying to call <code>context.res</code> to return a response to the caller, the function fails with the following exception:</p>
  
  <pre><code>2016-06-26T07:45:59.171 Exception while executing function: Functions.getSASToken. mscorlib: TypeError: context.res is not a function
      at module.exports (D:\home\site\wwwroot\getSASToken\index.js:63:26)
      at eval (eval at &lt;anonymous&gt; (C:\Program Files (x86)\SiteExtensions\Functions\0.2.10238\bin\edge\double_edge.js:34:28), &lt;anonymous&gt;:42:7).
  </code></pre>
  
  <p>Contents of the <code>function.json</code> file:</p>
  
  <pre><code>{
    "bindings": [
      {
        "webHookType": "",
        "name": "req",
        "type": "httpTrigger",
        "direction": "in",
        "authLevel": "anonymous"
      },
      {
        "name": "res",
        "type": "http",
        "direction": "out"
      }
    ],
    "disabled": false
  }
  </code></pre>
  
  <p>And the function in question:</p>
  
  <pre><code>module.exports = function(context, req) { 
      var token = req.query.token;
      var deviceId = req.query.deviceId;
  
      var resourceUri = util.format('%s/devices/%s', sbNamespace, deviceId);
  
      var sasToken = generateSasToken(resourceUri, token, null, 14400);
  
      context.res({
          status: 200,
          body: sasToken
      });
  
      context.done();
  }
  </code></pre>
  
  <p>Iterating through the <code>context.bindings</code> object shows that it only contains the property <code>req</code> (<code>res</code> is entirely missing).</p>
  
  <p>FYI, overriding the response object via <code>context.done(null, {res: {status:200, body: sasToken}}</code> does return the desired output to the caller.</p>