I want to get a specific block from an azure block blob with the blockId, is this even possible?
something like
var blockBlob = new BlockBlobClient(connectionString, containerName, blobName);
var blocklist = await GetBlobBlockList(blobName, cancellationToken);
var firstBlock = blocklist.First();
var memStream = new MemoryStream();
await blockBlob.DownloadStreamingAsync(memStream, firstBlock.Name);
2
Answers
It should be possible to do so however it won’t be as simple as you mentioned in your sample code.
Here’s what you would need to do:
0
ton - 1
block and add the size of each block.DownloadRangeToStreamAsync(Stream, Nullable<Int64>, Nullable<Int64>)
, where youroffset
value will be the sum of the size of each block calculated in step 2 andlength
value will be the size of the block you wish to download.You need to create a block blob below you can find the procedure:
you need to create a container under storage account as follows:
inside the container you can find the block blob under properties as shown below
To Get the block Id you can follow the code below:
code:
After getting the Block Id now you can get the certain block using the code below:
code:
In the above code you need to replace connection string, container name, block Id, blob name as below:
By following the above procedure, I got successfully.