I am pretty new to the world of MS Azure. I am trying to get the filenames and the last modified date for a bunch of files (block blobs) kept in my blob storage using Python. Here is the code that I am using:
import datetime
from azure.storage.blob import BlockBlobService
blob_service = BlockBlobService(account_name=account, account_key=acckey,protocol='http', request_session=sess)
blob_service.get_blob_to_path(container, pdfname, pdflocal)
generator = blob_service.list_blobs(container)
filenames = []
for blob in generator:
print (blob.name)
pdflocal = './' + blob.name
properties=blob_service.get_blob_to_path(container, blob.name,pdflocal)
date_year = datetime.datetime.fromtimestamp(os.path.getmtime("./"+blob.name) ).strftime('%Y-%m-%d %H:%M:%S')
print (date_year)
filenames.append(blob.name)
print len(filenames)
The problem here is, that the code tries to create a copy of my files and hence the last modified date is updated to the current date and time. How can I access the actual last modified date and time in Azure ML Studio?
I read about Blob.Properties.LastModified but it doesn't seem to work in python. One of the confusing things here was about converting the blobs in CloudBlobs. I am not sure if this has to be done within the Python script because the blobs in the Storage Explorer are of three types: Block, Page and Append. Am I missing something here?