Reputation: 12925
I am working with Block Blobs in Azure Storage. I need to get uncommitted blocks, as far as I have found I need to call "Get Block List". Here is the problem.
Does "Get Block List" functionality exists in C# (Microsoft.WindowsAzure.StorageClient.dll)?
MSDN only says about doing a HTTP request, not a word about StorageClient API.
If this function does not exists in C#, are there any plans to include it to the C# API?
Upvotes: 4
Views: 5994
Reputation: 66882
I think what you are looking for is the DownloadBlockList method on CloudBlockBlob http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblockblob.downloadblocklist.aspx
There's example code there in MSDN - http://msdn.microsoft.com/en-us/library/ee772860.aspx
static void DownloadBlockListForBlob(Uri blobEndpoint, string accountName, string accountKey)
{
//Create service client for credentialed access to the Blob service, using development storage.
CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));
//Get a reference to a block blob.
CloudBlockBlob blockBlob = blobClient.GetBlockBlobReference("mycontainer/mybinaryblob.mp3");
//Download the committed blocks in the block list.
foreach (var blockListItem in blockBlob.DownloadBlockList())
{
Console.WriteLine("Block ID: " + blockListItem.Name);
Console.WriteLine("Block size: " + blockListItem.Size);
Console.WriteLine("Is block committed?: " + blockListItem.Committed);
Console.WriteLine();
}
//Download only uncommitted blocks.
foreach (var blockListItem in blockBlob.DownloadBlockList(BlockListingFilter.Uncommitted))
{
Console.WriteLine("Block ID: " + blockListItem.Name);
Console.WriteLine("Block size: " + blockListItem.Size);
Console.WriteLine("Is block committed?: " + blockListItem.Committed);
Console.WriteLine();
}
//Download all blocks.
foreach (var blockListItem in blockBlob.DownloadBlockList(BlockListingFilter.All))
{
Console.WriteLine("Block ID: " + blockListItem.Name);
Console.WriteLine("Block size: " + blockListItem.Size);
Console.WriteLine("Is block committed?: " + blockListItem.Committed);
Console.WriteLine();
}
}
Upvotes: 6
Reputation: 136196
You may want to look into GetBlockListResponse class in Microsoft.WindowsAzure.StorageClient.Protocol namespace: http://msdn.microsoft.com/en-us/library/ee758632.aspx
Hope this helps
Thanks
Gaurav
Upvotes: 0