ashish
ashish

Reputation: 303

Generating sas token through azure cli max limit reached

I am trying to generate sas token through azure cli as show below

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

When executing the below bash command from bash and trying to upload a file greater than 256 mb i am getting the below error

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>

Upvotes: 0

Views: 276

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

Essentially you're encountering the restriction imposed by Azure Blob Storage Service. For Storage Service REST API version 2016-05-31 through version 2019-07-07, the maximum size of data that can be sent via Put Blob request is 256 MB. Please see this link for more details: https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob#remarks.

One possible solution is to make use of Put Block and Put Block List operations to split your large file into smaller chunks and then upload those chunks.

Another option is to make use of a Storage SDK to generate SAS token. When creating a SAS token, you can specify the Storage Service REST API version as a parameter. Then you should be able to specify a newer version (e.g. 2019-12-12 and later) which allows you to transfer larger files through Put Blob request. I was actually surprised to see it not being there in az storage container generate-sas.

Upvotes: 1

Related Questions