I have a list of file names that I need to search on Azure. Right now as a noob I am looping over each blob names and comparing strings but I think there has to be easiest and fast way to get this done. The current solution is making my HTTP response very slow.
def ifblob_exists(self, filename):
try:
container_name = 'xxx'
AZURE_KEY = 'xxx'
SAS_KEY = 'xxx'
ACCOUNT_NAME = 'xxx'
block_blob_service = BlockBlobService(account_name= ACCOUNT_NAME, account_key= None, sas_token = SAS_KEY, socket_timeout= 10000)
generator = block_blob_service.list_blobs(container_name)
for blob in generator:
if filename == blob.name:
print("\t Blob exists :"+" "+blob.name)
return True
else:
print('Blob does not exists '+filename)
return False
except Exception as e:
print(e)