【问题标题】:Is there a way to filter by tier in azure blob storage有没有办法在 azure blob 存储中按层过滤
【发布时间】:2021-05-06 18:06:53
【问题描述】:

我想列出存储在特定层中的所有文件。这是我尝试过的:

az storage fs file list \
  --file-system 'cold-backup' \
  --query "[?contains(properties.blobTier, 'Cold')==\`true\`].properties.blobTier"

但它不起作用。我也只尝试了“blobTier”。没有运气。

这是我得到的错误:

为“--query”提供的 jmespath 查询无效:在函数 contains() 中,值的类型无效:无,预期之一:['array','string'],收到:“null”

【问题讨论】:

    标签: azure azure-storage azure-blob-storage azure-cli


    【解决方案1】:

    命令az storage fs file list是针对ADLS Gen2文件系统的,输出中没有blobTier属性,所以你不能用它查询,blobTier也应该是Cool而不是Cold

    如果你想用blobTier列出文件过滤器,你可以使用az storage blob list,它适用于blob存储,但也可以用于ADLS Gen2文件系统。

    示例:

    az storage blob list --account-name '<storage-account-name>' --account-key 'xxxxxx' --container-name 'cold-backup' --query "[?properties.blobTier=='Cool']"
    

    如果要输出blobTier,请在命令中使用--query "[?properties.blobTier=='Cool'].properties.blobTier"

    【讨论】:

      猜你喜欢
      • 2020-05-03
      • 2021-04-23
      • 2021-11-08
      • 2020-08-15
      • 2020-02-24
      • 2020-02-21
      • 2020-02-26
      • 1970-01-01
      • 2012-12-26
      相关资源
      最近更新 更多