title: Azure Functions: How to read blob input for nodejs?
body: <p>I have setup an azure function which is triggered from a blob being added to a specific container.  The blob is a .zip file my intention is to use <code>adm-zip</code> to extract the blob to a directory and then read the contents.  I am confused about the the documentation here:
  <a href="https://github.com/Azure/azure-content/blob/master/articles/azure-functions/functions-bindings-storage.md#blob-trigger-supported-types" rel="nofollow noreferrer">https://github.com/Azure/azure-content/blob/master/articles/azure-functions/functions-bindings-storage.md#blob-trigger-supported-types</a>
  Which says the input parameter can be either an Object or String. I don't see any place in the function.json to specify what I want the input to be.</p>
  
  <p>In my code below, it the type seems to be a string, but since it doesn't print anything I assume it's actually a buffer of bytes representing the file contents.  In order to work with this, <strong>I tried to write the buffer to a local file, but it was not successful.  It did not throw an error or print out <code>saved blob to...</code></strong> </p>
  
  <p>In my function.json I have this:</p>
  
  <pre><code>{
    "bindings": [
      {
        "name": "xmlZipBlob",
        "type": "blobTrigger",
        "direction": "in",
        "path": "balancedataxml",
        "connection": "sc2iq_STORAGE"
      }
    ],
    "disabled": false
  }
  </code></pre>
  
  <p>And then I have <code>xmlZipBlob</code> as the second argument to my function:</p>
  
  <pre><code>var fs = require('fs');
  
  module.exports = function (context, xmlZipBlob) {
      context.log('Node.js blob trigger function processed blob:', xmlZipBlob);
      context.log(`typeof xmlZipBlob:`, typeof xmlZipBlob);
  
      fs.writeFile('xmlZip.zip', xmlZipBlob, (err) =&gt; {
          if (err) {
              throw err;
          }
  
          context.log('saved blob to loal file called xmlZip.zip');
          context.done();
      });
  };
  </code></pre>
  
  <p><strong>1. What is the type of the input paramater to the function for blobs?</strong></p>
  
  <p><strong>2. How do I control whether the input parameter is an Object or String?</strong></p>
  
  <p><strong>3. Is it possible to use the native node <code>fs</code> module to write to local file system for extracting .zip file?</strong></p>
  
  <p>Update: I believe this is failing due to attempting to use the file system and have opened separate more isolated question here:
  <a href="https://stackoverflow.com/questions/39218895/azure-functions-nodejs-what-are-restrictions-limitations-when-using-file-sys">Azure Functions: Nodejs, What are restrictions / limitations when using file system?</a></p>
  
  <p><strong>4. Is there a better alternative than using .zip files?</strong></p>
  
  <p>Until that is solved, I think I will have come up with different solution for dealing with the .zip file.  Either doing everything in memory with streams, or avoiding .zip files all together and just building a larger xml file out of the smaller xml files.  Either way, it seems there should be some documentation or warning on what it would take to port a node function that depends on the file system to an azure functions.</p>