title: Azure Blob Storage not Uploading
body: <p>I'm trying to upload a text file from a stream to AzureBlobStorage in .Net Core but it seems to be failing silently. I am reading data from a database and writing it into a <code>MemoryStream</code> using a <code>StreamWriter</code>. At the point I am uploading to BlobStorage, the <code>Stream</code> has a Length of 7147 so I know it's got data in it.</p>
  
  <p>Here's my code to upload the file:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public static async void UploadFromStream(string fileName, Stream stream, string fileExtenstion = "txt")
  {
      var storageAccount = CloudStorageAccount.Parse(_connectionString);
      var blobClient = storageAccount.CreateCloudBlobClient();
      var container = blobClient.GetContainerReference("logs");
      // By this point, I have a reference to my `logs` container which exists
      var blockBlob = container.GetBlockBlobReference($"{fileName}.{fileExtenstion}");
  
      try
      {
          stream.Position = 0;
          await blockBlob.UploadFromStreamAsync(stream);
      }
      catch (Exception e)
      {
          Console.WriteLine(e);
          throw;
      }
  }
  </code></pre>
  
  <p>Called by:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var memoryStream = new MemoryStream();
  using (var writer = new StreamWriter(memoryStream))
  {
      while (reader.Read())
      {
          writer.WriteLine(
              $"[{reader["Timestamp"]}][{reader["Level"].ToString().ToUpper()}] :: {reader["Message"]}{(!string.IsNullOrWhiteSpace(reader["Exception"].ToString()) ? " -- " + reader["Exception"] : "")}");
      }
      Task.Run(() =&gt; StorageService.UploadFromStream($"logfile_{DateTime.Today:s}", memoryStream)).Wait();
  }
  </code></pre>
  
  <p>I don't get inside my Catch block so I don't think I'm hitting any Exceptions, but when I check my Storage, there's nothing there. The application runs through with no errors.</p>
  
  <p>I have even tried using <code>byte[] bytes = stream.ToArray()</code> and using the <code>blockBlob.UploadFromByteArrayAsync</code> but still to no avail.</p>