Azure Storage - Generating SAS token (Portal vs PowerShell Azure Storage - Generating SAS token (Portal vs PowerShell powershell powershell

Azure Storage - Generating SAS token (Portal vs PowerShell


You could use the following cmdlet to generate SAS token, the result is same with Portal.

$now=get-dateNew-AzureStorageContainerSASToken -Name <container name> -Context $storageContext -Permission rwl -StartTime $now.AddHours(-1) -ExpiryTime $now.AddMonths(1)

My test result is below

?sv=2015-04-05&sr=c&sig=tMG2TwiAGXkDqwFbj7%2BRjI52qXUKU9NDI%2BmkxMY%2BjtM%3D&st=2017-05-22T00%3A41%3A50Z&se=2017-06-22T01%3A41%3A50Z&sp=rwl

You could check they are same except API version ?sv=2015-04-05. More information about SAS please refer to this link.

Update:

I know the reason, Azure Portal uses the latest API version to generate SAS token, but your local Azure PowerShell does not use the latest version.

You could use the following cmdlet to check your Azure PowerShell version.

Get-Module -ListAvailable -Name Azure -Refresh

On the latest version(for now 4.01) use the latest API version. You could download the mis installer from the link.

PS C:\Users\v-shshui> New-AzureStorageContainerSASToken -Name vhds -Context $storageContext -Permission rwl -StartTime $now.AddHours(-1) -ExpiryTime $now.AddMonths(1)?sv=2016-05-31&sr=c&sig=zdrwTEEmvTn6rjoJPVWOdQYzggrvygTHGoBsOBYgzuI%3D&st=2017-05-22T07%3A56%3A21Z&se=2017-06-22T08%3A56%3A21Z&sp=rwl