通过 azure cli 生成 sas 令牌达到最大限制

Generating sas token through azure cli max limit reached

我正在尝试通过 azure cli 生成 sas 令牌,如下所示

az storage container generate-sas --account-name aa--name etcd-backup --permissions acdlrw --expiry $expirydate --account-key xxx --https-only

当从 bash 执行以下 bash 命令并尝试上传大于 256 MB 的文件时,出现以下错误

url -X PUT -T $ss_backup_file -H "x-ms-date: $(date -u)" -H "x-ms-blob-type: BlockBlob" "https://$storage_account.blob.core.windows.net/$sa_container/Nebula/$ss_backup_file_name?$sas_token"

<Error><Code>RequestBodyTooLarge</Code><Message>The request body is too large and exceeds the maximum permissible limit
Time:2021-04-14T10:27:32.0287434Z</Message><MaxLimit>268435456</MaxLimit></Error>

基本上您遇到了 Azure Blob 存储服务施加的限制。对于存储服务 REST API 版本 2016-05-31 到版本 2019-07-07,可以通过 Put Blob request is 256 MB. Please see this link for more details: https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob#remarks.

发送的最大数据大小

一个可能的解决方案是利用 Put Block and Put Block List 操作将您的大文件拆分成较小的块,然后上传这些块。

另一种选择是使用存储 SDK 生成 SAS 令牌。创建 SAS 令牌时,您可以将存储服务 REST API 版本指定为参数。然后你应该能够指定一个更新的版本(例如 2019-12-12 及更高版本),它允许你通过 Put Blob 请求传输更大的文件。我真的很惊讶 az storage container generate-sas.

中没有它