Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does not found Listblob() in CloudBlobContainer

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())
        {

        }
like image 249
Janak Avatar asked Oct 16 '14 04:10

Janak


1 Answers

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).

like image 53
Serdar Ozler Avatar answered Sep 24 '22 02:09

Serdar Ozler