I created XML data using the C# XDocument library. And I tried to upload the XML data to an azure blob.
Below is my 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( "body",
new XElement( "level1",
new XElement( "level2", "text" ),
new XElement( "level2", "other text" ) ) ) );
MemoryStream stream = new MemoryStream();
doc.Save(stream);
var container = blobClient.GetContainerReference("folder location");
CloudBlockBlob blockBlob = container.GetBlockBlobReference("Data/xml/Data.csv");
await blockBlob.UploadFromStreamAsync(stream);
}
But the file is uploaded but there is nothing in the file. What is wrong with code?
file is available now.after adding based on Mario Vernari answer
xmlStream.Position = 0;

Data/xml/Data.csv? CSV is not XML. CSV is just a flat file with commas between values, an optional header and no other structure, eg1,2,3.14,4.5.csvextension Excel will try to open the file as if it was a CSV file - fields separated by commas, rows by newlines. In this case there are no commas, just newlines, so Excel loaded the file as single-column text.