// Create a CloudBlobClient object CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to the blob container CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); // Retrieve a reference to the blob CloudBlockBlob blob = container.GetBlockBlobReference("myblob"); // Retrieve the attributes of the blob blob.FetchAttributes(); // Display the attributes Console.WriteLine("Blob size: " + blob.Properties.Length); Console.WriteLine("Content type: " + blob.Properties.ContentType); Console.WriteLine("Creation time: " + blob.Properties.Created);
CloudBlockBlob blob = container.GetBlockBlobReference("myblob"); using (Stream stream = await blob.OpenReadAsync()) { // Retrieve the attributes of the blob await blob.FetchAttributesAsync(); // Display the size of the blob Console.WriteLine("Blob size: " + blob.Properties.Length); // Read the content of the blob byte[] buffer = new byte[blob.Properties.Length]; await stream.ReadAsync(buffer, 0, buffer.Length); // Convert the content to a string and display it string content = System.Text.Encoding.UTF8.GetString(buffer); Console.WriteLine("Blob content: " + content); }In this example, we retrieve a reference to a blob and use the FetchAttributesAsync method to retrieve its attributes. Then we open a read stream to the blob and read its content into a byte array. Finally, we convert the content to a string and display it along with the size of the blob. This code examples are written using C# programming language and the Microsoft.WindowsAzure.Storage.Blob package library must be installed to be able to use them.