jrichview
jrichview

Reputation: 390

Azure CloudBlobContainer.ListBlobs

I'm trying to update a command line utility someone else wrote years ago so that it will compile on current versions of Azure SDK. The breaking changes are biting me, especially on ListBlobs() method of CloudBlobContainer.

He constructed a BlobRequestOptions as follows:

BlobRequestOptions options = new BlobRequestOptions
{
    UseFlatBlobListing = true,
    BlobListingDetails = BlobListingDetails.Snapshots,
    AccessCondition = AccessCondition.IfNotModifiedSince(fetchParams.EndDate),
    RetryPolicy = RetryPolicies.Retry(10, RetryPolicies.DefaultClientBackoff),
    DeleteSnapshotsOption = DeleteSnapshotsOption.None
};

Obviously UseFlatBlobListing and BlobListingDetails are now just params to ListBlobs(). And I don't think I have to be concerned with DeleteSnapshotsOption now.

But I don't see how to specify the above AccessCondition, and that is a critical parameter.

Also, I don't know what RetryPolicies.DefaultClientBackoff used to do, and I don't see a similar name in the new RetryPolicy stuff.

Anyone have any advice on this?

Upvotes: 2

Views: 3384

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

Even with the older library, AccessCondition parameter was ignored when listing blobs. As you may already know, AccessCondition provides a mechanism for performing conditional operations (like delete blob only if it has not been modified since yesterday etc.) and is applicable only for certain operations. For a list of operations which can be performed only if certain conditions are matched, please see here: http://msdn.microsoft.com/en-us/library/windowsazure/dd179371.aspx. So as far as listing blobs are concerned, I would say don't worry about the access conditions as it is not applicable in this particular operation.

Retry policies, as the name suggests allows you to instruct storage client library to retry an operation in case a transient error occurs. In version 2.0, retry policies have moved into a separate namespace: Microsoft.WindowsAzure.Storage.RetryPolicies.

I wrote some blog posts on migrating code from older storage client library to version 2.0. I think these two posts may be useful to you in the context of your question:

Storage Client Library 2.0 – Migrating Blob Storage Code: http://gauravmantri.com/2012/11/28/storage-client-library-2-0-migrating-blob-storage-code/

Storage Client Library 2.0 – Implementing Retry Policies: http://gauravmantri.com/2012/12/30/storage-client-library-2-0-implementing-retry-policies/

Upvotes: 4

Related Questions