'Problem Generating Azure ADLS Gen2 SAS Token for Container with Python?
From azure.storage.blob I'm using the function generate_container_sas. I'm trying to generate a SAS token for a container in an ADLS Gen2 storage account in Azure. I can go into azure portal and generate a working SAS token using an account key with no issues. The token works just fine. However, when I do what I think is the same thing in python I get a token back but when I load it into storage explorer it says "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.". I have validated all the inputs appear to be correct. The token that is generated looks like:
https://<STORAGE_ACCOUNT>.blob.core.windows.net/<CONTAINER_NAME>?se=2022-02-19T05%3A41%3A26Z&sp=rwdlac&sv=2020-10-02&sr=c&sig=jCd8AAatl5o9QsbMHtlca6oNnnRdKqtcOnWN3sZa1c8%3D
sas_token = generate_container_sas(
account_name=account_name,
container_name=container_name,
account_key=account_key,
permission=AccountSasPermissions(read=True, list=True, write=True, delete=True, create=True, add=True),
expiry=datetime.utcnow() + timedelta(hours=expiry_hours)
)
Solution 1:[1]
I believe the issue is that you are using AccountSasPermissions instead of ContainerSasPermissions. Can you try by changing the following line of code:
permission=AccountSasPermissions(read=True, list=True, write=True, delete=True, create=True, add=True),
to
permission=ContainerSasPermissions(read=True, list=True, write=True, delete=True),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gaurav Mantri |
