title: How to create a XML FIle and upload to azure blob in C#
body: <p>I created XML data using the C# <code>XDocument</code> library. And I tried to upload the XML data to an azure blob.
  Below is my code.</p>
  <pre><code> using Microsoft.WindowsAzure.Storage;
   using Microsoft.WindowsAzure.Storage.Blob;
   using System.Xml.Linq;
   public CloudBlobClient blobClient {get;}
  
  public AzureBlobServices(string storageAccountConnection)
  {
   StorageAccountConnection = storageAccountConnection;
   storageAccount = CloudStorageAccount.Parse(StorageAccountConnection);
   blobClient = storageAccount.CreateCloudBlobClient();
  }
  
       public async Task sampleFile()
       {
        XDocument doc = new XDocument( new XElement( &quot;body&quot;, 
                                      new XElement( &quot;level1&quot;, 
                                      new XElement( &quot;level2&quot;, &quot;text&quot; ), 
                                      new XElement( &quot;level2&quot;, &quot;other text&quot; ) ) ) );
              MemoryStream stream = new MemoryStream();
              doc.Save(stream);
              var container = blobClient.GetContainerReference(&quot;folder location&quot;);
              CloudBlockBlob blockBlob = container.GetBlockBlobReference(&quot;Data/xml/Data.csv&quot;);
              await blockBlob.UploadFromStreamAsync(stream);
  }
  </code></pre>
  <p>But the file is uploaded but there is nothing in the file. What is wrong with code?</p>
  <p>file is available now.after adding  based on Mario Vernari answer<br />
  xmlStream.Position = 0;
  <a href="https://i.stack.imgur.com/qJI9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qJI9L.png" alt="enter image description here" /></a></p>