Warm tip: This article is reproduced from serverfault.com, please click

Does not found Listblob() in CloudBlobContainer

发布于 2014-10-16 04:54:51

In my app i want all the blob of my container but in my code (as below) there is not Listblob() method in CloudBlobContainer variable container. Am i missing something?

var credentials = new StorageCredentials("xxx", "a37bijfRGGdgaVU+ITEIi0Cp1VrbzMM7Bc9PbMOw2FPAz9twgR+lbTzqGhBfHeJe7UfEp4CXtLxqY5Ek0/5zdg==");
        var client = new CloudBlobClient(new Uri("https://xxx.blob.core.windows.net/"), credentials);
        var container = client.GetContainerReference("publicimage");

//this container variable has not ListBlobs() method
        foreach(IListBlobItem item in container.ListBlobsSegmentedAsync())
        {

        }
Questioner
Janak
Viewed
0
4,144 2020-10-21 21:23:48

ListBlobs is a synchronous method and therefore is missing on platforms that do not support synchronous methods such as Windows Phone. The reason is that calling a synchronous method on a UI thread would block the UI and make the application unresponsive.

The alternative is to use the *Async overloads. However, please note that there is no ListBlobsAsync, because there is no async counterpart of IEnumerable in .NET. So, you should call ListBlobsSegmentedAsync and handle the continuation token that it returns.

If you would like to see an example usage, I would recommend looking at Azure Storage Client Library's unit tests (see test CloudBlobContainerListBlobsSegmentedAsync in CloudBlobContainerTest.cs).