Does not found Listblob() in CloudBlobContainer
Asked Answered
B

2

10

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

        }
Barrow answered 16/10, 2014 at 4:54 Comment(8)
Which version of storage client library are you using?Nagey
@GauravMantri I believe it should not matter, since ListBlob is available since 1.7 msdn.microsoft.com/en-us/library/azure/…Kinchen
I guess your package references are not correct. @Zanak can you confirm that you used nuget to add package references?Kinchen
@Kinchen I think it would as there have been some changes in the functions between 1.7 and 2.0. Also if I understand correctly, functions are different between full .Net storage client library and .Net storage client library for Windows 8/Windows Phone apps.Nagey
@Kinchen ya i install windows azure storage package from Nuget.Barrow
@GauravMantri is right, ListBlobs would be missing if the platform does not support synchronous methods.Allargando
@SerdarOzler-Microsoft so wp8.1 doesn't support that? An other idea to do?Barrow
@Zanak, yes, you will not find ListBlobs in the Windows Phone library. I just added an answer to give you more details.Allargando
A
16

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

Allargando answered 16/10, 2014 at 21:41 Comment(2)
Link to the usage example is brokenBacteriostat
Replacing the broken link in the answer: Here is a link to an example in the same project.Reitz
J
0

Add these two Nuget packages and you will be able to find Listblobs

  <package id="Microsoft.Azure.Common" version="2.2.1" targetFramework="net46" />
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net46" />
Jer answered 28/11, 2020 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.