Azure - update existing xml file in blob storage

I have XML files stored in the BLOB repository, and I'm trying to figure out what is the most efficient way to update them (and / or add some elements to them). In WebRole, I came up with the following:

using (MemoryStream ms = new MemoryStream())
{                    
      var blob = container.GetBlobReference("file.xml");
      blob.DownloadToStream(msOriginal);
      XDocument xDoc= XDocument.Load(ms);  

      // Do some updates/inserts using LINQ to XML.  

      blob.Delete();//Details about this later on.

      using(MemoryStream msNew = new MemoryStream())  
      {
           xDoc.Save(msNew);
           msNew.Seek(0,SeekOrigin.Begin);
           blob.UploadFromStream(msNew);                    
      }                               
}

I consider these parameters in terms of efficiency:

  • BLOB Transactions .
  • The Bandwidth . (Not sure if it is counted because the code works in a data center)
  • The memory in the copy.

Some things to mention:

  • My xml files are about 150-200 KB.

  • , XDocument (XmlWriter XmlReader) . , BlobStream ( ).

  • blob.Delete(), , xml blob , . . , ( , ).

, , , , , , ?

+5
2

, , , , , , . , , , .

. blob , . , ( 1/3 ) .

var blob = container.GetBlobReference("file.xml");
var xml = blob.DownloadText(); // transaction 1
var xDoc= XDocument.Parse(xml);

// Do some updates/inserts using LINQ to XML.

blob.UploadText(xDoc.ToString()); //  transaction 2

, , ( ), , .

var blob = container.GetBlobReference("file.xml");
var xDoc= new XDocument(/* generate file */);

blob.UploadText(xDoc.ToString()); // transaction 1
+5

, XDocument , (XmlWriter XmlReader) .

, . . koolaid , . . , .

, ( ), (-)? , ? , ? (: )

Flush(), Delete , . , , .

+1

All Articles