如何在azure blob存储中仅枚举blob名称

时间:2014-06-16 09:47:49

标签: c# azure azure-storage-blobs

我需要一种最快的方法来枚举容器中的所有blob名称。容器包含大约60万个blob。现在我列举如下:

while(true) {
...         
 var blobChank = azureClient.ListBlobs(null, true, BlobListingDetails.None, null, null).Skip(counter * chankSize).Take(chankSize).ToList();
 if(blobChank.Count == 0) break;
 counter++;
...
///retrieve blob names

1 个答案:

答案 0 :(得分:0)

您可以访问BlobProperties以获取名称:

var blobChank = ... ;
foreach (object o in blobChank)
{
    BlobProperties bp = o as BlobProperties;
    if (bp != null)
    {
        BlobProperties p = _Container.GetBlobProperties(bp.Name);
        var name = p.Name; // get the name
    }
}

或通过Linq:

  

列出blobNames = blobChank。选择(b =>(b as   CloudBlockBlob)请将.Name);

并且对于迭代速度,您可以在本地下载blob,请参见此处:http://gallery.technet.microsoft.com/scriptcenter/all-Blobs-with-Snapshots-3b184a79