BlobStorage.Advanced.GetExistingBlobReferenceAsync C# (CSharp) Method

GetExistingBlobReferenceAsync() private static method

Gets a reference to a blob by making a request to the service.
private static GetExistingBlobReferenceAsync ( Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container, string blobName ) : System.Threading.Tasks.Task
container Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer The container.
blobName string The blob name.
return System.Threading.Tasks.Task
        private static async Task GetExistingBlobReferenceAsync(CloudBlobContainer container, string blobName)
        {
            try
            {
                // Get a reference to a blob with a request to the server.
                // If the blob does not exist, this call will fail with a 404 (Not Found).
                ICloudBlob blob = await container.GetBlobReferenceFromServerAsync(blobName);

                // The previous call gets the blob's properties, so it's not necessary to call FetchAttributes
                // to read a property.
                Console.WriteLine("Blob {0} was last modified at {1} local time.", blobName,
                    blob.Properties.LastModified.Value.LocalDateTime);
            }
            catch (StorageException e)
            {
                if (e.RequestInformation.HttpStatusCode == 404)
                {
                    Console.WriteLine("Blob {0} does not exist.", blobName);
                    Console.WriteLine("Additional error information: " + e.Message);
                }
                else
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                    throw;
                }
            }

            Console.WriteLine();
        }