Reputation: 161
I have multiple files in an Azure blob. I want to read/download only the latest file. How can I do it via python.
Note: I am using azure ML datastores to connect to the container in which the blob resides.
Upvotes: 0
Views: 3146
Reputation: 8606
In order to perform logic based on blob properties, you'll have to interact with your blob container.
Ensure that you've got the azure-storage-blob
library :
conda install azure-storage-blob
(or pip install
if that's your preference)
In the Azure Portal, navigate to your storage account, choose Access Keys in the left-hand rail, and copy one of your Connection Strings. Also, know the name of the blob container holding your blobs.
Connect and do logic:
from azure.storage.blob import ContainerClient
container = ContainerClient.from_connection_string(conn_str={your_connection_string}, container_name = {your_container_name})
for blob in container.list_blobs():
print(f'{blob.name} : {blob.last_modified}')
Upvotes: 2