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);
blob.Delete();
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
, .
.
, (
, ).
, , , , , , ?