Cloud​Block​Blob.​Create​Snapshot​Async Method

Definition

Overloads

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.

Examples

This code example creates a new block blob, then takes a snapshot of that block blob. The snapshot is created with unique metadata.

private static async Task CreateBlockBlobSnapshotAsync(CloudBlobContainer container)  
{  
    // Create a new block blob in the container.  
    CloudBlockBlob baseBlob = container.GetBlockBlobReference("sample-base-blob.txt");  

    // Add blob metadata.  
    baseBlob.Metadata.Add("ApproxBlobCreatedDate", DateTime.UtcNow.ToString());  

    try  
    {  
        // Upload the blob to create it, with its metadata.  
        await baseBlob.UploadTextAsync(string.Format("Base blob: {0}", baseBlob.Uri.ToString()));  

        // Sleep 5 seconds.  
        System.Threading.Thread.Sleep(5000);  

        // Create a snapshot of the base blob.  
        // Specify metadata at the time that the snapshot is created to specify unique metadata for the snapshot.  
        // If no metadata is specified when the snapshot is created, the base blob's metadata is copied to the snapshot.  
        Dictionary<string, string> metadata = new Dictionary<string, string>();  
        metadata.Add("ApproxSnapshotCreatedDate", DateTime.UtcNow.ToString());  
        CloudBlockBlob snapshot = await baseBlob.CreateSnapshotAsync(metadata, null, null, null);  

        Console.WriteLine("Snapshot created: {0}", snapshot.SnapshotQualifiedUri);  
        Console.WriteLine("Snapshot time: {0}", snapshot.SnapshotTime);  
    }  
    catch (StorageException e)  
    {  
        Console.WriteLine(e.Message);  
        Console.ReadLine();  
        throw;  
    }  
}  

CreateSnapshotAsync()

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

[Microsoft.WindowsAzure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task<Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob> CreateSnapshotAsync ();
Returns

A Task<TResult> object of type CloudBlockBlob that represents the asynchronous operation.

Attributes

CreateSnapshotAsync(CancellationToken)

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

[Microsoft.WindowsAzure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task<Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob> CreateSnapshotAsync (System.Threading.CancellationToken cancellationToken);
Parameters
cancellationToken
CancellationToken

A CancellationToken to observe while waiting for a task to complete.

Returns

A Task<TResult> object of type CloudBlockBlob that represents the asynchronous operation.

Attributes

CreateSnapshotAsync(IDictionary<String,String>, AccessCondition, BlobRequestOptions, OperationContext)

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

[Microsoft.WindowsAzure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task<Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob> CreateSnapshotAsync (System.Collections.Generic.IDictionary<string,string> metadata, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext);
Parameters
metadata
IDictionary<String,String>

A collection of name-value pairs defining the metadata of the snapshot.

accessCondition
AccessCondition

An AccessCondition object that represents the condition that must be met in order for the request to proceed. If null, no condition is used.

options
BlobRequestOptions

A BlobRequestOptions object that specifies additional options for the request.

operationContext
OperationContext

An OperationContext object that represents the context for the current operation.

Returns

A Task<TResult> object of type CloudBlockBlob that represents the asynchronous operation.

Attributes

CreateSnapshotAsync(IDictionary<String,String>, AccessCondition, BlobRequestOptions, OperationContext, CancellationToken)

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

[Microsoft.WindowsAzure.Storage.DoesServiceRequest]
public virtual System.Threading.Tasks.Task<Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob> CreateSnapshotAsync (System.Collections.Generic.IDictionary<string,string> metadata, Microsoft.WindowsAzure.Storage.AccessCondition accessCondition, Microsoft.WindowsAzure.Storage.Blob.BlobRequestOptions options, Microsoft.WindowsAzure.Storage.OperationContext operationContext, System.Threading.CancellationToken cancellationToken);
Parameters
metadata
IDictionary<String,String>

A collection of name-value pairs defining the metadata of the snapshot.

accessCondition
AccessCondition

An AccessCondition object that represents the condition that must be met in order for the request to proceed. If null, no condition is used.

options
BlobRequestOptions

A BlobRequestOptions object that specifies additional options for the request.

operationContext
OperationContext

An OperationContext object that represents the context for the current operation.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for a task to complete.

Returns

A Task<TResult> object of type CloudBlockBlob that represents the asynchronous operation.

Attributes