-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"exists" operator for containers and blobs #9507
Comments
Hi @subesokun thank you for letting us know, we will look into this //cc: @rakshith91 @mayurid |
Hi @subesokun
|
@rakshith91 Thanks for the hint! This is a bit off-topic, but is there any documentation available that tells me which exceptions can be thrown by a certain function call? That would've helped me a lot to figure out on my own that e.g. |
Hi @subesokun |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage. |
Are there any updates on this? I would really appreciate a For the record, here's what I currently am doing to check for whether a blob exists, but it's far more verbose than it really should be. from azure.storage.blob import BlobClient
from azure.core.exceptions import ResourceNotFoundError
def exists(blob_url: str) -> bool:
blob_client = BlobClient.from_blob_url(blob_url)
try:
blob_client.get_blob_properties()
except ResourceNotFoundError:
return False
return True
valid_blob_uri = "https://lilablobssc.blob.core.windows.net/nacti-unzipped/part0/sub000/2010_Unit150_Ivan097_img0003.jpg"
invalid_blob_uri = "https://lilablobssc.blob.core.windows.net/nacti-unzipped/part0/sub000/2010_Unit150_Ivan000_img0003.jpg"
assert exists(valid_blob_uri)
assert not exists(invalid_blob_uri) |
Hi @chrisyeh96 |
Both container.exists() (releasing soon) and blob.exists() are now available. I will close this issue :) |
Add
exists
operator toContainerClient
andBlobClient
to verify if the given container or blob is existing.See related feature request for
azure-sdk-for-js
Azure/azure-sdk-for-js#5062The text was updated successfully, but these errors were encountered: