question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
goyash17commented, Mar 5, 2021

@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…

1reaction
tasherif-msftcommented, Mar 4, 2021

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found