Sergey
Sergey

Reputation: 8071

How to get all blobs with are stored inside azure storage container

I have azure container with name "images" but I can't figure out how to get all blobs which are stored inside this container

Upvotes: 3

Views: 707

Answers (1)

Sergey
Sergey

Reputation: 8071

I have found the answer:

// We get reference for the container (by name "containerName" variable)
container = blobClient.GetContainerReference(containerName);

// We create the container if this container is not exists
container.CreateIfNotExist();

// Set permissions
var permissions = new BlobContainerPermissions 
{ 
    PublicAccess = blobContainerPublicAccessType.Blob 
};
container.SetPermissions(permissions);

// Get list of all blobs URLs which are stored inside container
IEnumerable<IListBlobItem> blobs = container.ListBlobs();
return blobs.Select(item => item.Uri.ToString()).ToList();

Upvotes: 4

Related Questions