4

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?

2 Answers 2

6

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();
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Well this is it. I have already tryed this method, but without a filter option. It is strange that the empty method does not return all blocks ... This confused me and I thought that uncommited block are not returned via this method. Thanks, that you point that out!
Your MSDN links are stale: "We're sorry, the page you requested cannot be found."
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.