Exporter (0) Imprimer
Développer tout
EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

CloudBlob.CreateSnapshot Method (BlobRequestOptions)

Updated: April 24, 2013

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Creates a snapshot of the blob, using a conditional request based on the BlobRequestOptions that you specify.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

'Utilisation
Dim instance As CloudBlob
Dim options As BlobRequestOptions
Dim returnValue As CloudBlob

returnValue = instance.CreateSnapshot(options)

public CloudBlob CreateSnapshot (
	BlobRequestOptions options
)

Parameters

options

Type: Microsoft.WindowsAzure.StorageClient.BlobRequestOptions

An object that specifies any additional options for the request.

Return Value

Type: Microsoft.WindowsAzure.StorageClient.CloudBlob

A blob snapshot.


static void CreateBlobSnapshot2(Uri blobEndpoint, string accountName, string accountKey)
{
    // Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    // Get a reference to a blob.
    CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");

    // Set options for the request. E.g., Specify an operation timeout of 20 seconds.
    BlobRequestOptions ssOptions = new BlobRequestOptions();
    ssOptions.Timeout = TimeSpan.FromSeconds(20.0);

    // Take a snapshot of the blob.
    CloudBlob snapshot = blob.CreateSnapshot(ssOptions);

    // Get the snapshot timestamp.
    DateTime timestamp = (DateTime)snapshot.Attributes.Snapshot;

    // Use the timestamp to get a second reference to the snapshot.
    CloudBlob snapshot2 = new CloudBlob("mycontainer/myblob.txt", timestamp, blobClient);

    // Write out the snapshot URI.
    Console.WriteLine(snapshot2.Uri);
}

Snapshots provide read-only versions of blobs. Once a snapshot has been created, it can be read, copied, or deleted, but not modified.

A snapshot is itself a blob, and can be represented by a CloudBlob object or one of its derived objects.

When you create a snapshot, the blob's Snapshot property returns a DateTime value that uniquely identifies the snapshot relative to its base blob. You can use this value to perform further operations on the snapshot. Note that this DateTime value is opaque.

You can use a snapshot to restore a blob to an earlier version by copying over a base blob with its snapshot.

noteNote
You are charged for unique blocks or pages stored in association with a blob. Creating a snapshot does not incur an additional charge against your storage account for blocks or pages used, as the snapshot does not use additional storage resources but instead shares blocks or pages with the base blob, as long as they remain identical. As you add new blocks or pages to the base blob, you are charged for the storage capacity used by these new blocks or pages.

Copying Blob Properties and Metadata

When you create a snapshot of a blob, the following system properties are copied to the snapshot with the same values:

The base blob's committed block list is also copied to the snapshot, if the blob is a block blob. Any uncommitted blocks are not copied.

The metadata associated with the base blob is copied to the snapshot.

Specifying an Access Condition

You can specify an access condition so that the snapshot is created only if a condition is met. To specify an access condition, use the AccessCondition property. If the specified condition is not met, the snapshot is not created, and the Blob service returns status code HTTPStatusCode.PreconditionFailed.

Copying Snapshots

When a base blob is copied, any snapshots of the base blob are not copied to the destination blob. When a destination blob is overwritten with a copy, any snapshots associated with the destination blob stay intact under its name.

You can copy a snapshot blob over its base blob to restore an earlier version of a blob. The snapshot remains, but the base blob is overwritten with a copy that can be both read and written.

noteNote
Promoting a snapshot in this way does not incur an additional charge for storage resources, since blocks or pages are shared between the snapshot and the base blob.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

 

Afficher:
© 2014 Microsoft