Synchronize Files to Azure blob
-
Monday, December 14, 2009 3:44 AMHi,
I have download the samples from http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3638 I was able to upload files from filesystem to Azure blob however the download says "creating file... but i dont see any files created in the targetted directory. Initially it was error at FileRetreiver.cs as shown below
public string AbsoluteSourceFilePath
{
get
{
throw new NotImplementedException("Absolute Path Not Supported");
}
}
I change this code to return the path but file is not created. Am i missing anything?
It will be nice if you guys create New root level category like SyncFx-AzureSynchronization.
Thanks.- Moved by Max Wang_Chinasoft Tuesday, April 19, 2011 10:48 PM Forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
All Replies
-
Monday, December 14, 2009 4:30 AM
It works only if i set the value of RelativePath to Empty. I also noticed that Delete method leads to concurrency violation hence i modified to
blob.Delete(opts); --Leads to concurrency violation
blob.DeleteIfExists();--Does the delete without error.
Not sure why but it works.
Thanks.- Marked As Answer by Liam Cavanagh - MSFTMicrosoft Employee, Owner Wednesday, December 16, 2009 6:54 PM
-
Saturday, December 19, 2009 1:07 PM
"Delete method leads to concurrency violation"
Do you mean in AzureBlobStore.cs @ line 373 (in DeleteFile)?// Specify an optimistic concurrency check to prevent races with other endpoints syncing at the same time. BlobRequestOptions opts = new BlobRequestOptions(); opts.AccessCondition = AccessCondition.IfNotModifiedSince(expectedLastModified); try { blob.Delete(opts); }The problem is that the ListBlobs request is not bringing back the LastModified DateTime, so the AccessCondition is never met and you get a violation.
So DeleteIfExists just works because it doesn't check the concurrency condition.
To fix this (and probably other issues) add a call to FetchAttributes to the ListBlobs method in AzureBlobStore.cs:foreach (IListBlobItem o in Container.ListBlobs(opts)) { CloudBlob blob = Container.GetBlobReference(o.Uri.ToString()); blob.FetchAttributes(); // Add this line to ensure that attributes are enumerated ItemFieldDictionary dict = new ItemFieldDictionary();