Reputation: 426
I am trying to list all the jpg files in my blob. When I use this code
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs();
All the files in that particular blob are listed
I have tried to modify the above code but the modified code does not list anything.
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs().OfType<CloudBlobContainer>().OrderByDescending(b => b.Name).Where(b => b.Name.EndsWith(".jpg"));
Upvotes: 1
Views: 2034
Reputation: 71031
Just to close out this question properly: The issue is that the query code is inadvertently checking for containers within the container, not blobs within the container:
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs().OfType<CloudBlobContainer>().OrderByDescending(b => b.Name).Where(b => b.Name.EndsWith(".jpg"));
The last line should be changed to:
var blobs = container1.ListBlobs().OfType<CloudBlockBlob>()...
Upvotes: 4