Azure存储:仅返回BlobTier Cold中的Azure存储中的Blob

时间:2019-01-11 17:03:51

标签: azure-storage-blobs azure-cli

我有以下Azure Cli命令,该命令列出了给定存储帐户和容器中的文件:

az storage blob list --container-name $web  --account-name mystorageaccount

在运行时,它会以JSON格式正确返回所有结果。

我希望将返回的结果限制为当前使用冷层存储的那些项。

例如将properties.BlobTier设置为Cold的地方。

例如返回的响应之一如下所示:

{
    "content": null,
    "deleted": false,
    "metadata": null,
    "name": "index.html",
    "properties": {
      "appendBlobCommittedBlockCount": null,
      "blobTier": "Cold",
      "blobTierChangeTime": "2019-01-11T16:50:59+00:00",
      "blobTierInferred": false,
      "blobType": "BlockBlob",
      "contentLength": 564,
      "contentRange": null,
      "contentSettings": {
        "cacheControl": null,
        "contentDisposition": null,
        "contentEncoding": null,
        "contentLanguage": null,
        "contentMd5": "J46oaHVXow+85uEF58la/w==",
        "contentType": "text/html"
      },
      "copy": {
        "completionTime": null,
        "id": null,
        "progress": null,
        "source": null,
        "status": null,
        "statusDescription": null
      },
      "creationTime": "2019-01-11T15:03:18+00:00",
      "deletedTime": null,
      "etag": "0x8D677E4F6791B3D",
      "lastModified": "2019-01-11T16:50:59+00:00",
      "lease": {
        "duration": null,
        "state": "available",
        "status": "unlocked"
      },
      "pageBlobSequenceNumber": null,
      "remainingRetentionDays": null,
      "serverEncrypted": true
    },
    "snapshot": null
  },

The documentation for the Azure CLI's storage blob list,表示它支持全局参数--query。

基于对文档的阅读,看来我应该能够执行以下查询,但随后没有任何结果(而且我知道有些项目很冷):

az storage blob list --container-name $web  --account-name mystorageaccount --query 'properties[?blobTier == 'Cold']'

有人知道我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

我想出了我问题的答案。 The following article gave a bunch more examples on how to properly select and filter data.

结果,我能够提出导致预期行为的以下内容。


        beforeMount(){
            var that = this;
            function importAll (r) {
              r.keys().forEach(key => that.imgCache[key] = r(key));
            }

            importAll(require.context('../assets/flags/', true, /\.png$/));
        },
        computed: {
            src(){
                var key = `./flag-${this.country}.png`,
                    url = this.imgCache[key];

                return url;
            }
        },