Azure Storage container size

前端 未结 5 986
无人共我
无人共我 2020-12-11 01:42

How can I get a size of container in Azure Storage? I access Azure storage via C# API:

var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettin         


        
5条回答
  •  鱼传尺愫
    2020-12-11 02:21

    Targeting .NET Core 2, ListBlobs method is not available because you can access only async methods.

    So you can get Azure Storage Container size using ListBlobsSegmentedAsync method

    BlobContinuationToken continuationToken = null;
    long totalBytes = 0;
    do
    {
        var response = await container.ListBlobsSegmentedAsync(continuationToken);
        continuationToken = response.ContinuationToken;
        totalBytes += response.Results.OfType().Sum(s => s.Properties.Length);
    } while (continuationToken != null);
    

提交回复
热议问题