azureazure-storageazure-blob-storageblobstorageblobs

Listing the files, which are inside a Blob?


Just started working on with Windows Azure and Mapreduce. I've already created an HDInsight cluster within the Azure Portal and also created a Block Blob using the Azure Explorer named BlobFiles.

What I wanted to know is, is there a way of listing all the files within a Blob which is within a Blob Container? In other words if I'm uploading text files as well as images to the same Blob, how could I list those text files as well as those images programmatically or in another way?

Searched for a solution, but still couldn't come across of one. I'm able to see the content of the file individually using the Azure Explorer, where as um unable to find a way to see or display the files within that particular Blob!

Edited: This is what I've tried to display the Blobs:

        // Retrieve storage account from connection string.
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
            CloudConfigurationManager.GetSetting("StorageConnectionString"));

        // Create the blob client.
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

        // Retrieve reference to a previously created container.
        CloudBlobContainer container = blobClient.GetContainerReference("fyptest1");

        // Retrieve reference to a blob named "myblob".
        CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");

        lboxblob.ItemsSource = container.ListBlobs();//lboxblob is the name of my listbox

When I tried the above code it displays something like Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob, and so on for a few number of times.

Any help would be appreciated.


Solution

  • Each Azure storage "blob" is a "file." You want to list the "blobs" in a "blob container," most likely.

    To do this, use the CloudBlobContainer.ListBlobs() method.

    https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx