【问题标题】:How to find the number of objects in an Azure blob container - Archive Tier如何查找 Azure blob 容器中的对象数 - 存档层
【发布时间】:2020-05-15 09:21:51
【问题描述】:

我们正在尝试将一些压缩备份文件从 Azure 存档层重新混合到冷却层。我们并不关心数据大小本身(10TB)的价格。我们担心的是移动单个文件层的潜在 I/O 费用。备份过程将每个作业保存在“块”(即文件夹)中,其中包含大小不同的单个压缩块的文件树。在整个 10TB 中可能有 10 万或 1000 亿个这些单独的块,我们不知道。

是否有任何 PowerShell 脚本/命令可以提供整个 10TB blob 容器中单个对象的计数?如果我们可以确定对象的数量,我们就可以计算 I/O 成本。我们有命令行访问权限,并且知道某些 API 调用仅返回 5000 个项目块的结果。我们也知道任何递归搜索都可能需要很多时间。

【问题讨论】:

    标签: azure azure-blob-storage


    【解决方案1】:
    $storageAccount = Get-AzStorageAccount `
      -ResourceGroupName $resourceGroup `
      -Name $storageAccountName
    
    $blobCount = 0
    $token = $null
    $MaxReturn = 5000
    
    do {
        $Blobs = Get-AzStorageBlob -Context $storageAccount.Context -Container $containerName `
            -MaxCount $MaxReturn -ContinuationToken $token
        if ( -not $Blobs ) { break } # not sure if this is needed
        $blobCount = $blobCount + $Blobs.Count
        $token = $Blobs[$Blobs.Count - 1].ContinuationToken;
    } while ( $token )
    

    这是我想出的“脚本”。基于this

    【讨论】:

    • 谢谢你!您知道调用 Get-AzStorageBlob API 是否会产生任何费用?这是递归的吗?
    • 当然有,10000 次操作的 0.1c 之类的荒谬。我不确定每个调用都算作一次操作,可能是因为您正在列出
    猜你喜欢
    • 2013-07-12
    • 1970-01-01
    • 2019-03-20
    • 2021-09-23
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    • 2020-07-22
    • 1970-01-01
    相关资源
    最近更新 更多