I am trying to list and download blobs from a container on Azure. It works perfectly fine when I try to do so using storage account access key. However, fails when use a SAS token. I generated the SAS token the with the following PowerShell script:
$storageContext = New-AzureStorageContext -StorageAccountName "myAccount" -StorageAccountKey "<account key>"
$permission = "rwdl"
$sasToken = New-AzureStorageContainerSASToken -Name "myContainer" -Policy "testPolicy" -Context $storageContext >>sastoken.txt
"
I get the following result:
?sv=2017-04-17&sr=c&si=testPolicy&sig=dbS680%2FXgPp4o%2BQCCzpYzGZszCnDHVjCkdHZRf6KDeg%3D
I appended the sas token with resource URI to get:
https://myAccount.blob.core.windows.net/myContainer?sv=2017-04-17&sr=c&si=testPolicy&sig=dbS680%2FXgPp4o%2BQCCzpYzGZszCnDHVjCkdHZRf6KDeg%3D
and ran the following CLI command:
az storage blob list --container-name myContainer --account-name myAccount --auth-mode key --debug --sas-token "https://myAccount.blob.core.windows.net/myContainer?sv=2017-04-17&sr=c&si=testPolicy&sig=dbS680%2FXgPp4o%2BQCCzpYzGZszCnDHVjCkdHZRf6KDeg%3D" >> bloblist.txt
I get the following error:
azure.multiapi.storage.v2018_03_28.common.storageclient : Client-Request-ID=0f7a 7762-3729-11e9-8b32-ffc4c9592d0a Retry policy did not allow for a retry: Server- Timestamp=Sat, 23 Feb 2019 05:08:30 GMT, Server-Request-ID=21f07a6a-f01e-00e9-32 35-cb7d5c000000, HTTP status code=403, Exception=Server failed to authenticate t he request. Make sure the value of Authorization header is formed correctly incl uding the signature. ErrorCode: AuthenticationFailed
AuthenticationFailed
Server failed to auth enticate the request. Make sure the value of Authorization header is formed corr ectly including the signature.RequestId:21f07a6a-f01e-00e9-3235-cb7d5c000000Time :2019-02-23T05:08:30.7149353ZSignature size is invalid.
You do not have the required permissions needed to perform this operation. Depending on your operation, you may need to be assigned one of the following ro les:
"Storage Blob Data Contributor (Preview)"
"Storage Blob Data Reader (Preview)"
"Storage Queue Data Contributor (Preview)"
"Storage Queue Data Reader (Preview)"
If you want to use the old authentication method and allow querying for the righ t account key, please use the "--auth-mode" parameter and "key" value.
Event: CommandInvoker.OnFilterResult [] 'CommandResultItem' object is not iterable Traceback (most recent call last): File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-r8nye8gm\knack\knack\cl i.py", line 212, in invoke File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-r8nye8gm\knack\knack\ou tput.py", line 132, in out File "C:\Users\VSSADM~1\AppData\Local\Temp\pip-install-r8nye8gm\knack\knack\ou tput.py", line 38, in format_json TypeError: 'CommandResultItem' object is not iterable telemetry.save : Save telemetry record of length 2499 in cache
I have tried generating a storage account level SAS portal, but didnt find any luck.
Please help!