Azure Blobs: get a list of blocks in C #

I work with Block Blobs in Azure Storage. I need to get unblocked blocks, as far as I found, I need to call "Get a list of blocks". Here is the problem.

Is there a Get List of Blocks feature in C # (Microsoft.WindowsAzure.StorageClient.dll)?

MSDN is only talking about making an HTTP request, not about the StorageClient API.

If this function does not exist in C #, are there any plans to include it in the C # API?

+3
source share
2 answers

I think you are looking for the DownloadBlockList method on CloudBlockBlob http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblockblob.downloadblocklist.aspx

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();
    }
}
+4

GetBlockListResponse Microsoft.WindowsAzure.StorageClient.Protocol: http://msdn.microsoft.com/en-us/library/ee758632.aspx

,

Gaurav

0

All Articles