title: Hash mismatch (integrity check failed) with Azure Blob Storage
body: <p>I'm following <a href="http://willi.am/blog/2014/07/03/azure-blob-storage-and-node-downloading-blobs/" rel="nofollow">http://willi.am/blog/2014/07/03/azure-blob-storage-and-node-downloading-blobs/</a>.</p>
  
  <p>However despite the exact same code, when I download blobs Azure gives the error:</p>
  
  <p>[Error: Hash mismatch (integrity check failed), Expected value is ...]</p>
  
  <p>The line being run is  blobService.getBlobToText, with blobService being the connection to Azure (createBlobService...)</p>
  
  <p>What's going on? :S</p>
  
  <p>My code's below:</p>
  
  <pre><code>    // Azure test
      function downloadImageAsText(blobService, containerName, blobName) {
  
           blobService.getBlobToText(
                containerName,
                blobName,
                function(err, blobContent, blob) {
                    if (err) {
                        console.error("Couldn't download blob %s", blobName);
                        console.error(err);
                    } else {
                        console.log("Sucessfully downloaded blob %s", blobName);
                        console.log(blobContent);
                    }
                });
  
      }
  
      function uploadImage(blobService, containerName, blobName, fileName) {
  
        blobService.getBlobProperties(
          containerName,
          blobName,
          function(err, properties, status) {
              if (status.isSuccessful) {
                  // Blob exists
              } else {
                  blobService.createBlockBlobFromLocalFile(
                      containerName,
                      blobName,
                      fileName,
                      function(error, result, response){
                          if(error){
                              console.log("Couldn't upload file %s", fileName);
                              console.error(error);
                          } else {
                              console.log('File %s uploaded successfully', fileName);
                              downloadImageAsText(blobService, containerName, blobName);
                          }
                      });
              }
          });
      }
  
  
      function testAzure() {
  
        accountName / hash = my details
  
        var storage = require('azure-storage');
        var blobService = storage.createBlobService(accountName, hash);
        var containerName = 'tst';
        var blobName = 'test.png';
        var fileName = 'test.png';
  
        blobService.createContainerIfNotExists(containerName, function(err, result, response) {
            if (err) {
                console.log("Couldn't create container %s", containerName);
                console.error(err);
            } else {
                if (result) {
                    console.log('Container %s created', containerName);
                    uploadImage(blobService, containerName, blobName, fileName);
                } else {
                    console.log('Container %s already exists', containerName);
                    uploadImage(blobService, containerName, blobName, fileName);
                }
            }
        });
      }
  
      function startServer() {
        http = require('http');
        const PORT = 8080;
        var server = http.createServer(handleRequest);
        server.on('listening',function(){
          console.log("Server listening on: http://178.62.117.207:%s", PORT);
        });
        server.listen(PORT);
      }
  
      startServer();
      testAzure();
  </code></pre>