Cloud​Block​Blob Class

Definition

Represents a blob that is uploaded as a set of blocks.

public class CloudBlockBlob : Microsoft.WindowsAzure.Storage.Blob.CloudBlob, Microsoft.WindowsAzure.Storage.Blob.ICloudBlob
Inheritance
CloudBlockBlob
Implements

Inherited Members

Microsoft.WindowsAzure.Storage.Blob.CloudBlob

Examples

This code example creates a new block blob with a random name, and writes some text to it.

private static async Task<CloudBlockBlob> CreateRandomlyNamedBlockBlobAsync(CloudBlobContainer container)  
{  
    // Get a reference to a blob that does not yet exist.  
    // The GetBlockBlobReference method does not make a request to the service, but only creates the object in memory.  
    string blobName = "sample-blob-" + Guid.NewGuid();  
    CloudBlockBlob blob = container.GetBlockBlobReference(blobName);  

    // For the purposes of the sample, check to see whether the blob exists.  
    Console.WriteLine("Blob {0} exists? {1}", blobName, await blob.ExistsAsync());  

    try  
    {  
        // Writing to the blob creates it on the service.  
        await blob.UploadTextAsync(string.Format("This is a blob named {0}", blobName));  
    }  
    catch (StorageException e)  
    {  
        Console.WriteLine(e.Message);  
        Console.ReadLine();  
        throw;  
    }  

    // Check again to see whether the blob exists.  
    Console.WriteLine("Blob {0} exists? {1}", blobName, await blob.ExistsAsync());  

    return blob;  
}  

Remarks

Block blobs are optimized for upload large amounts of data efficiently. For details about block blobs, see Understanding Block Blobs, Append Blobs, and Page Blobs.

Constructors

Cloud​Block​Blob(​Uri)

Initializes a new instance of the CloudBlockBlob class using an absolute URI to the blob.

Cloud​Block​Blob(​Uri, ​Storage​Credentials)

Initializes a new instance of the CloudBlockBlob class using an absolute URI to the blob.

Cloud​Block​Blob(​Storage​Uri, ​Nullable<​Date​Time​Offset>, ​Storage​Credentials)

Initializes a new instance of the CloudBlockBlob class using an absolute URI to the blob.

Cloud​Block​Blob(​Uri, ​Nullable<​Date​Time​Offset>, ​Storage​Credentials)

Initializes a new instance of the CloudBlockBlob class using an absolute URI to the blob.

Properties

Stream​Write​Size​In​Bytes

Gets or sets the block size for writing to a block blob.

Methods

Begin​Create​Snapshot(​Async​Callback, ​Object)

Begins an asynchronous operation to create a snapshot of the blob.

Begin​Create​Snapshot(​IDictionary<​String,​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to create a snapshot of the blob.

Begin​Download​Block​List(​Async​Callback, ​Object)

Begins an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Begin​Download​Block​List(​Block​Listing​Filter, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Begin​Download​Text(​Async​Callback, ​Object)

Begins an asynchronous operation to download the blob's contents as a string.

Begin​Download​Text(​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to download the blob's contents as a string.

Begin​Open​Write(​Async​Callback, ​Object)

Begins an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Begin​Open​Write(​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Begin​Put​Block(​String, ​Stream, ​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a single block.

Begin​Put​Block(​String, ​Stream, ​String, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a single block.

Begin​Put​Block​List(​IEnumerable<​String>, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a list of blocks to a new or existing blob.

Begin​Put​Block​List(​IEnumerable<​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a list of blocks to a new or existing blob.

Begin​Start​Copy(​Cloud​Block​Blob, ​Async​Callback, ​Object)

Begins an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Begin​Start​Copy(​Cloud​File, ​Async​Callback, ​Object)

Begins an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Begin​Start​Copy(​Cloud​Block​Blob, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Begin​Start​Copy(​Cloud​File, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Begin​Upload​From​Byte​Array(​Byte[], ​Int32, ​Int32, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​Byte​Array(​Byte[], ​Int32, ​Int32, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​File(​String, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​File(​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​Stream(​Stream, ​Int64, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​Stream(​Stream, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​Stream(​Stream, ​Int64, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Begin​Upload​From​Stream(​Stream, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Begin​Upload​Text(​String, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.

Begin​Upload​Text(​String, ​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Async​Callback, ​Object)

Begins an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.

Create​Snapshot(​IDictionary<​String,​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Creates a snapshot of the blob.

Create​Snapshot​Async()

Initiates an asynchronous operation to create a snapshot of the blob.

Create​Snapshot​Async(​Cancellation​Token)

Initiates an asynchronous operation to create a snapshot of the blob.

Create​Snapshot​Async(​IDictionary<​String,​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to create a snapshot of the blob.

Create​Snapshot​Async(​IDictionary<​String,​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to create a snapshot of the blob.

Download​Block​List(​Block​Listing​Filter, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Returns an enumerable collection of the blob's blocks, using the specified block list filter.

Download​Block​List​Async(​Block​Listing​Filter, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Download​Block​List​Async(​Block​Listing​Filter, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Download​Block​List​Async()

Initiates an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Download​Block​List​Async(​Cancellation​Token)

Initiates an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

Download​Text(​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Downloads the blob's contents as a string.

Download​Text​Async()

Initiates an asynchronous operation to download the blob's contents as a string.

Download​Text​Async(​Cancellation​Token)

Initiates an asynchronous operation to download the blob's contents as a string.

Download​Text​Async(​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to download the blob's contents as a string.

Download​Text​Async(​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to download the blob's contents as a string.

End​Create​Snapshot(​IAsync​Result)

Ends an asynchronous operation to create a snapshot of the blob.

End​Download​Block​List(​IAsync​Result)

Ends an asynchronous operation to return an enumerable collection of the blob's blocks, using the specified block list filter.

End​Download​Text(​IAsync​Result)

Ends an asynchronous operation to download the blob's contents as a string.

End​Open​Write(​IAsync​Result)

Ends an asynchronous operation to open a stream for writing to the blob.

End​Put​Block(​IAsync​Result)

Ends an asynchronous operation to upload a single block.

End​Put​Block​List(​IAsync​Result)

Ends an asynchronous operation to upload a list of blocks to a new or existing blob.

End​Upload​From​Byte​Array(​IAsync​Result)

Ends an asynchronous operation to upload the contents of a byte array to a blob.

End​Upload​From​File(​IAsync​Result)

Ends an asynchronous operation to upload a file to a blob.

End​Upload​From​Stream(​IAsync​Result)

Ends an asynchronous operation to upload a stream to a block blob.

End​Upload​Text(​IAsync​Result)

Ends an asynchronous operation to upload a string of text to a blob.

Open​Write(​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Opens a stream for writing to the blob. If the blob already exists, it will be overwritten.

Open​Write​Async()

Initiates an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Open​Write​Async(​Cancellation​Token)

Initiates an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Open​Write​Async(​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Open​Write​Async(​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to open a stream for writing to the blob. If the blob already exists, it will be overwritten.

Put​Block(​String, ​Stream, ​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a single block.

Put​Block​Async(​String, ​Stream, ​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a single block.

Put​Block​Async(​String, ​Stream, ​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a single block.

Put​Block​Async(​String, ​Stream, ​String)

Initiates an asynchronous operation to upload a single block.

Put​Block​Async(​String, ​Stream, ​String, ​Cancellation​Token)

Initiates an asynchronous operation to upload a single block.

Put​Block​List(​IEnumerable<​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a list of blocks to a new or existing blob.

Put​Block​List​Async(​IEnumerable<​String>)

Initiates an asynchronous operation to upload a list of blocks to a new or existing blob.

Put​Block​List​Async(​IEnumerable<​String>, ​Cancellation​Token)

Initiates an asynchronous operation to upload a list of blocks to a new or existing blob.

Put​Block​List​Async(​IEnumerable<​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a list of blocks to a new or existing blob.

Put​Block​List​Async(​IEnumerable<​String>, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a list of blocks to a new or existing blob.

Start​Copy(​Cloud​Block​Blob, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Begins an operation to start copying another block blob's contents, properties, and metadata to this block blob.

Start​Copy(​Cloud​File, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Begins an operation to start copying an Azure file's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​File, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​Block​Blob, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​Block​Blob, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​File, ​Access​Condition, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​Block​Blob, ​Cancellation​Token)

Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​File)

Initiates an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​Block​Blob)

Initiates an asynchronous operation to start copying another block blob's contents, properties, and metadata to this block blob.

Start​Copy​Async(​Cloud​File, ​Cancellation​Token)

Initiates an asynchronous operation to start copying a file's contents, properties, and metadata to this block blob.

Upload​From​Byte​Array(​Byte[], ​Int32, ​Int32, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Upload​From​Byte​Array​Async(​Byte[], ​Int32, ​Int32)

Initiates an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Upload​From​Byte​Array​Async(​Byte[], ​Int32, ​Int32, ​Cancellation​Token)

Initiates an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Upload​From​Byte​Array​Async(​Byte[], ​Int32, ​Int32, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Upload​From​Byte​Array​Async(​Byte[], ​Int32, ​Int32, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload the contents of a byte array to a blob. If the blob already exists, it will be overwritten.

Upload​From​File(​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a file to the Blob service. If the blob already exists, it will be overwritten.

Upload​From​File​Async(​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Upload​From​File​Async(​String, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Upload​From​File​Async(​String)

Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Upload​From​File​Async(​String, ​Cancellation​Token)

Initiates an asynchronous operation to upload a file to a blob. If the blob already exists, it will be overwritten.

Upload​From​Stream(​Stream, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream(​Stream, ​Int64, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Int64, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Int64, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Cancellation​Token)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Int64)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​From​Stream​Async(​Stream, ​Int64, ​Cancellation​Token)

Initiates an asynchronous operation to upload a stream to a block blob. If the blob already exists, it will be overwritten.

Upload​Text(​String, ​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Uploads a string of text to a blob. If the blob already exists, it will be overwritten.

Upload​Text​Async(​String, ​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context)

Initiates an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.

Upload​Text​Async(​String)

Initiates an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.

Upload​Text​Async(​String, ​Cancellation​Token)

Initiates an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.

Upload​Text​Async(​String, ​Encoding, ​Access​Condition, ​Blob​Request​Options, ​Operation​Context, ​Cancellation​Token)

Initiates an asynchronous operation to upload a string of text to a blob. If the blob already exists, it will be overwritten.