ListBlobs not available in cloudblobdirectory class?

Viewed 4293

I have installed the latest windows azure nuget packages in my .net core 2.0 project. Installed version : 8.6.0.0

In the 8.1.4 version, i have get the list of items using listblobs method using the below syntax.

CloudBlobDirectory sampleDirectory = container.GetDirectoryReference(path);
                IEnumerable<IListBlobItem> items = sampleDirectory.ListBlobs(false, BlobListingDetails.Metadata);

when is try to use the same code block in .net core 2.0 project with 8.6.0.0 windows azure version, it throws error as

"cloudblobdirectory does not contain a definition for listblobs".

How to get the file items in this version?

Similarly , UploadText() method in "CloudBlockBlob" also not available in this version.

any one please suggest the solution for this issue ?

1 Answers

any one please suggest the solution for this issue ?

As Gaurav Mantri mentioned that Net core implementation of storage client library only includes async methods. There're no sync methods available.

Please have try to use following demo code. I also do a demo on my side, it works correctly.

var blobs = sampleDirectory.ListBlobsSegmentedAsync(false, BlobListingDetails.Metadata, 100, null, null, null).Result;

Demo code:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("Storage connection string");

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

// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("Container name");

// Create the container if it doesn't already exist.
container.CreateIfNotExistsAsync();
CloudBlobDirectory sampleDirectory = container.GetDirectoryReference("directory name");

var blobs = sampleDirectory.ListBlobsSegmentedAsync(false, BlobListingDetails.Metadata, 100, null, null, null).Result;

enter image description here

Related