从 Azure 存储帐户下载时如何查看 blob 名称?

问题描述 投票:0回答:1

我在 azure 存储帐户中有一个 blob,正在使用以下内容尝试下载:

 az storage blob download --account-name <storage-account-name> --account-key <storage-account-key> --container-name <container-name> --name <blob-name> --file <local-file-path>

问题是什么,我可以从哪里得到它?

这是从存储帐户下载的正确方法吗?

azure-blob-storage
1个回答
0
投票

这是从存储帐户下载的正确方法吗?

如果您需要下载特定文件,您的命令是正确的。

从 Azure 存储帐户下载时如何查看 blob 名称?

首先,使用以下命令列出 Azure Blob 存储中的文件。

命令:

az storage blob list --account-name "<Your-storage account -name>" --container-name "<Your -container name>" --account-key "<Your-key>" --query "[].name" --output tsv

输出:

PS C:\Windows\system32> az storage blob list --account-name "venkat789" --container-name "demo" --account-key "xxx" --query "[].name" --output tsv
sample html file download.html
sample.png

enter image description here

上面的命令列出了

demo
存储帐户的
venkat789
容器中所有 Blob 的名称,并使用指定的帐户密钥进行身份验证。输出显示两个 blob 名称:“sample html file download.html”和“sample.png”。

现在,如果您需要下载特定的 blob(例如 example.png),您可以使用相同的命令。

命令和输出:

PS C:\Windows\system32> az storage blob download --account-name "venkat789" --container-name "demo" --account-key "xxxx" --name "sample.png" --file "C:\Users\xxxxx\example.png"
Alive[################################################################]  100.0000%
Finished[#############################################################]  100.0000%
{
  "container": "demo",
  "content": "",
  "contentMd5": null,
  "deleted": false,
  "encryptedMetadata": null,
  "encryptionKeySha256": null,
  "encryptionScope": null,
  "hasLegalHold": null,
  "hasVersionsOnly": null,
  "immutabilityPolicy": {
    "expiryTime": null,
    "policyMode": null
  },
  "isAppendBlobSealed": null,
  "isCurrentVersion": true,
  "lastAccessedOn": null,
  "metadata": {},
  "name": "sample.png",
  "objectReplicationDestinationPolicy": null,
  "objectReplicationSourceProperties": [],
  "properties": {
    "appendBlobCommittedBlockCount": null,
    "blobTier": null,
    "blobTierChangeTime": null,
    "blobTierInferred": null,
    "blobType": "BlockBlob",
    "contentLength": 18063,
    "contentRange": "bytes None-None/18063",
    "contentSettings": {
      "cacheControl": null,
      "contentDisposition": null,
      "contentEncoding": null,
      "contentLanguage": null,
      "contentMd5": "xxxxx",
      "contentType": "image/png"
    },
    "copy": {
      "completionTime": null,
      "destinationSnapshot": null,
      "id": null,
      "incrementalCopy": null,
      "progress": null,
      "source": null,
      "status": null,
      "statusDescription": null
    },
    "creationTime": "2024-01-16T05:25:53+00:00",
    "deletedTime": null,
    "etag": "xxxx"",
    "lastModified": "2024-01-16T05:25:53+00:00",
    "lease": {
      "duration": null,
      "state": "available",
      "status": "unlocked"
    },
    "pageBlobSequenceNumber": null,
    "pageRanges": null,
    "rehydrationStatus": null,
    "remainingRetentionDays": null,
    "serverEncrypted": true
  },
  "rehydratePriority": null,
  "requestServerEncrypted": true,
  "snapshot": null,
  "tagCount": null,
  "tags": null,
  "versionId": "20xxxx69385Z"
}

下载的文件保存到指定的本地文件路径,输出显示下载的 blob 的属性。

如果需要下载更多文件,可以使用

az storage blob download-batch
命令。

参考:

© www.soinside.com 2019 - 2024. All rights reserved.