3

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 ?

3
  • If I remember correctly, .Net core implementation of storage client library only includes async methods. There're no sync methods available. Commented Nov 18, 2017 at 13:14
  • Yes @gauravMantri. Is any idea for getting the files using this async method. I tried in my side with below code CloudBlobDirectory sampleDirectory = container.GetDirectoryReference(path); Task<BlobResultSegment> item = sampleDirectory.ListBlobsSegmentedAsync(true, BlobListingDetails.Metadata, null, null, options, context); but results return as null Commented Nov 20, 2017 at 4:26
  • Shouldn't you be awaiting the async operation? Try the following line of code: Task<BlobResultSegment> item = await sampleDirectory.ListBlobsSegmentedAsync(true, BlobListingDetails.Metadata, null, null, options, context);. HTH. Commented Nov 20, 2017 at 5:29

1 Answer 1

10

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.