azure-cli: az storage account generate-sas creating invalid token (Expiry format incorrect)

Expiry portion of the SAS token ends up like: se=2019-12-12T03%3A21%3A25Z

Where it should be like: se=2019-12-12T03:21:25Z

I have no idea where that format is valid but for most practical uses it seems like complete gibberish (e.g if passing token to azcopy)

Furthermore az cli should generate sas tokens in identical format to the Azure Portal for consistency sake. Azure Portal generated SAS: ?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2119-11-12T10:31:28Z&st=2019-11-12T02:31:28Z&spr=https&sig=REDACTED

Azure CLI generated SAS: se=2019-12-12T03%3A21%3A25Z&sp=rwdlacup&sv=2018-03-28&ss=bqtf&srt=sco&sig=REDACTED

Command Name az storage account generate-sas

  • az storage account generate-sas --account-name {} --services {} --permissions {} --resource-type {} --expiry {} --output {}

Environment Summary

Linux-5.3.7-050307-generic-x86_64-with-debian-buster-sid
Python 3.6.5
Shell: bash

azure-cli 2.0.76

Extensions:
interactive 0.4.3

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

This is a snippet of a working example for AzCopy

EXPIRE=$(date -u -d "3 months" '+%Y-%m-%dT%H:%M:%SZ')
START=$(date -u -d "-1 day" '+%Y-%m-%dT%H:%M:%SZ')
SAS=$(az storage account generate-sas --account-name $ACCOUNT --account-key $KEY --start $START --expiry $EXPIRE --https-only --permissions acdlpruw --resource-types sco --services bfqt | sed 's/%3A/:/g;s/\"//g')

Hi @Juliehzl Zunli Hu FTE, the diagnosis is probably not correct, since SAS generated from Storage Explorer works perfectly fine. Ex:

https://zemaintest.blob.core.windows.net/bar?sv=2019-02-02&st=2020-05-27T09%3A27%3A01Z&se=2020-05-28T09%3A27%3A01Z&sr=c&sp=rl&sig=REDACTED

The SAS should be URL encoded, and it should work with AzCopy. Have you been able to repro this issue on your end?

I have tried with Azcopy 10.3.4 and the sas token generated with azure cli 2.6.0. it works to me. @nofunatall can you have a try again? and if there is any problem, could you provide log file to help figure out root cause?

azcopy copy "https://zuhlrs.blob.core.windows.net/test1/test0.txt?se=2020-05-30T00%3A00%3A00Z&sp=rwu&spr=https&sv=2018-03-28&ss=b&srt=sco&sig=READACTED" a.txt