title: How to upload a file using Node JS function in Azure
body: <p>I am trying to create an Azure function that handles file upload. I have tried different options (trying to read from request directly or using formidable).</p>
  
  <p>For both these cases I am getting following error when the function is executed.</p>
  
  <pre><code>Exception while executing function: Functions.UploadFile. mscorlib: TypeError: req.on is not a function  
      at IncomingForm.parse (D:\home\site\wwwroot\node_modules\formidable\lib\incoming_form.js:117:6)  
      at module.exports (D:\home\site\wwwroot\UploadFile\index.js:5:10)  
      at D:\Program Files (x86)\SiteExtensions\Functions\1.0.11702\bin\azurefunctions\functions.js:106:24.  
  </code></pre>
  
  <p>The function code is as below</p>
  
  <pre><code>var formidable = require("formidable");  
  
  module.exports = function (context, request) {  
      context.log('JavaScript HTTP trigger function processed a request.');      
      var form = new formidable.IncomingForm();  
      form.parse(request, function (err, fields, files) {  
          context.res = { body : "uploaded"};  
      });  
      context.done();  
  };  
  </code></pre>
  
  <p>Any help is appreciated. </p>