I believe that the accepted answer is confusing and poorly explained. My preferences are as follows:
To create a transition file (that is: this name gives it context), I use the Azure Blob virtual storage directories and name blob using Seconds from the era .
An example is if you have a directory with the path "SomeContainer / SomeFolder /". This directory contains one or more files named using the Seconds Since Epoch mentioned above. To get the "last" or last file, use the following:
StorageCredentials cred = new StorageCredentials("{{YOUR ACCOUNT NAME}}", ""{{YOUR ACCOUNT KEY}}"); CloudStorageAccount storageAccount = new CloudStorageAccount(cred, true); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); //invoke the blob client CloudBlobContainer container = blobClient.GetContainerReference("SomeContainer"); //get your container reference CloudBlobDirectory directory = container.GetDirectoryReference("SomeFolder"); //resolve the directory IListBlobItem latestBlobItem = directory.ListBlobs(true, BlobListingDetails.All).LastOrDefault(); //get the latest blobItem CloudBlockBlob blockBlob = null; if(latestBlobItem != null && !String.IsNullOrWhiteSpace(latestBlobItem.Uri.LocalPath)) { //get the blob local path string fullLocalPath = latestBlobItem.Uri.LocalPath; //remove container and leading slash string localPath = fullLocalPath.Substring(fullLocalPath.IndexOf('/', 1) + 1); //get your blob reference blockBlob = container.GetBlockBlobReference(localPath); }
From there, do as you want using the block block link (download, etc.).
Happy sob!
source share