有没有办法在 azure blob 存储中按层过滤

Is there a way to filter by tier in azure blob storage

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

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

但是没用。我也只尝试使用“blobTier”。运气不好。

这是我得到的错误:

为“--query”提供的 jmespath 查询无效:在函数 contains() 中,值类型无效:None,应为:['array'、'string'] ,收到:“空”

命令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"