6

Is there way to determine Last Access Time of the Azure storage files apart from log analytics . So, does anyone ever come across this situation, what would be the best way to achieve this? Or am I too concerned about this?

Thank you in advanced.

1 Answers1

0

In Azure file storage, there is no option till date to know the last opened/viewed/accessed time, but there is a possibility to get to know about the last modified file. In case you are looking for that, here's a C# way:

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("<Your Connection string>");
CloudFileClient cloudFileClient = cloudStorageAccount.CreateCloudFileClient();
CloudFileShare cloudFileShare = cloudFileClient.GetShareReference("<Your File Share Name>");
IEnumerable<IListFileItem> fileShareItemsList = cloudFileShare.GetRootDirectoryReference().ListFilesAndDirectories();

foreach (IListFileItem listItem in fileShareItemsList)
{
  if (listItem is CloudFile) // Checking direct files under the root directory for now
  {
    CloudFile file = (CloudFile)listItem;
    file.FetchAttributes(); // this is mandatory to fetch modified time
    DateTime lastModifiedTime = file.Properties.LastModified; // Here's the time!
    // Use it in your logic..
  }
}

Deepak
  • 2,660
  • 2
  • 8
  • 23