ContainerClient exists method does not work with Container level SAS token.
See original GitHub issue- azure-storage-blob:
- 12.8.0:
- macOS:
- 3.8:
Describe the bug ContainerClient exists method does not work with Container level SAS token.
Error -
azure.core.exceptions.HttpResponseError: This request is not authorized to perform this operation.
RequestId:9c51628a-d01e-0000-3135-119766XXXXX
Time:2021-03-04T20:29:12.8555087Z
ErrorCode:AuthorizationFailure
Error:None
To Reproduce Steps to reproduce the behavior: Call the below code with SAS token generated at the container level.
container_client = ContainerClient(account_url='https://ABC.blob.core.windows.net/',
credential='<SAS>',
container_name='<CONTAINER_NAME>',
max_block_size=1000000,
max_single_put_size=1000000,
min_large_block_upload_threshold=1000000,
max_single_get_size=1000000,
max_chunk_get_size=1000000,
connection_timeout=2,
timeout=5)
print(container_client.exists())
Expected behavior True/False should be returned.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
container_client.create_container() fails when using Container ...
Your SAS token has been generated at Storage level, not at Container level, yes? I'm pretty sure because Storage level tokens start with...
Read more >azure.storage.blob.ContainerClient class | Microsoft Learn
A client to interact with a specific container, although that container may not yet exist. For operations relating to a specific blob within...
Read more >How do you check that a container exists in Azure Blob ...
In v12, there are 2 ways to check if the container exists or not. ... I have the following method to get a...
Read more >azure-storage-blob - PyPI
ContainerClient - this client represents interaction with a specific container (which need not exist yet), and allows you to acquire preconfigured client ...
Read more >azure.storage.blob package - NET
If the URL already has a SAS token, specifying an explicit credential will take ... If the container is not found, a ResourceNotFoundError...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@tasherif-msft : I am from @varun-shahdadpuri team. After going through ContainerClient class, i see that get_account_information() can be used with a container/blob level SAS. I tested and can confirm that it works successfully when container exists and returns “azure.core.exceptions.HttpResponseError: Operation returned an invalid status” error if container does not exist. can you review this analysis and provide feedback on this…
@varun-shahdadpuri unfortunately you would need to have an account level SAS to find out if a container exists or not.
Sorry once again for the inconvenience