title: Azure Function: Unzip file works in debug but not in production
body: <p>This is my very first Azure function. I need to unzip a file after it is uploaded on an Azure Storage Blob.<br>
  I found this video <a href="https://www.youtube.com/watch?v=GRztpy337kU" rel="nofollow noreferrer">https://www.youtube.com/watch?v=GRztpy337kU</a> and this post: <a href="https://msdevzone.wordpress.com/2017/07/07/extract-a-zip-file-stored-in-azure-blob" rel="nofollow noreferrer">https://msdevzone.wordpress.com/2017/07/07/extract-a-zip-file-stored-in-azure-blob</a>.<br>
  Using Visual Studio 2017 with C#, all works fine when i run the function in Visual Studio but when i deploy it to Azure, nothing is extracted. If i watch the log all seems ok.<br>
  Here is my code:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.IO.Compression;
  using Microsoft.Azure.WebJobs;
  using Microsoft.Azure.WebJobs.Host;
  using Microsoft.WindowsAzure.Storage;
  
  namespace ExtractZipFunction
  {
      public static class ScompattaZip
      {
          [FunctionName("ScompattaZip")]
          public static void Run([BlobTrigger("input-files/{name}", Connection = "connectionStorage")]
                                  Stream myBlob, string name, TraceWriter log)
  
          {
              log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
              try
              {
                  string destinationStorage = Environment.GetEnvironmentVariable("destinationStorage");
                  string destinationContainer = Environment.GetEnvironmentVariable("destinationContainer");
                  log.Info($"destinationStorage: {destinationStorage}");
                  log.Info($"destinationContainer: {destinationContainer}");
  
                  if (System.IO.Path.GetExtension(name).ToLower() == ".zip")
                  {
                      log.Info("It's a zip");
                      var archive = new ZipArchive(myBlob);
                      var storageAccount = CloudStorageAccount.Parse(destinationStorage);
                      var blobClient = storageAccount.CreateCloudBlobClient();
                      var container = blobClient.GetContainerReference(destinationContainer);
  
                      foreach (var entry in archive.Entries)
                      {
                          var blockBlob = container.GetBlockBlobReference(entry.FullName);
                          using (var fileStream = entry.Open())
                          {
                              if (entry.Length &gt; 0)
                              {
                                  log.Info($"Estrazione 1 - {entry.FullName}");
                                  blockBlob.UploadFromStreamAsync(fileStream);
                                  log.Info($"Estrazione 2 - {entry.FullName}");
                              }
                          }
                      }
                  }
                  else
                      log.Info("Not a zip");
              }
              catch (Exception ex)
              {
                  log.Info($"Errore: {ex.Message}");
              }
          }
      }
  }
  </code></pre>
  
  <p>And this is the log in Azure:</p>
  
  <pre><code>C# Blob trigger function Processed blob
   Name:EmptyJSONFile_1033.zip 
   Size: 24294 Bytes
  destinationStorage: DefaultEndpointsProtocol=https;AccountName=[...]
  destinationContainer: outputfiles
  E' uno zip
  Estrazione EmptyJSONFile_1033.ico
  Estrazione 1 - EmptyJSONFile_1033.ico
  Estrazione 2 - EmptyJSONFile_1033.ico
  Estrazione EmptyJSONFile_1033.vstemplate
  Estrazione 1 - EmptyJSONFile_1033.vstemplate
  Estrazione 2 - EmptyJSONFile_1033.vstemplate
  Estrazione json.json
  Estrazione 1 - json.json
  Estrazione 2 - json.json
  </code></pre>
  
  <p>All seems OK but at the end of the function the container outputfiles is empty!</p>
  
  <p>What am I doing wrong?</p>