Bit of a wordy title, but I am not sure how else to phrase it. I am doing some work on Azure Storage Account Blobs, and I want to get the Metadata for each blob, which is done by calling a method on that object. Currently, I am using a looping construct to call the method like so
IEnumerable<IListBlobItem> listOfBlobs =
cloudBlobContainer.ListBlobs(blobName, true, BlobListingDetails.Snapshots);
foreach (IListBlobItem blobItem in listOfBlobs)
{
CloudBlockBlob theBlob = blobItem as CloudBlockBlob;
theBlob.FetchAttributes();
Console.WriteLine("Snapshot Uri: {0}", theBlob.SnapshotQualifiedUri.AbsoluteUri);
}
I am wondering if there is a more elegant way of doing this. I know that I can typically do
listOfBlobs.ForEach(item => SomeMethod(item))
But since FetchAttributes
is a void method, it will fail at build time because it needs to return an IEnumerable<T>
to use foreach
. My question is: how do I call FetchAttributes()
for all items in the list? Am I better off using the loop? Is there some Linqy way of doing it?