如何将所有blob存储在azure存储容器中

时间:2013-03-31 19:42:24

标签: asp.net-mvc azure

我有一个名为“images”的天蓝色容器,但我无法弄清楚如何获取存储在此容器内的所有blob

1 个答案:

答案 0 :(得分:4)

我找到了答案:

// 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();