(0) exportieren Drucken
Alle erweitern

CloudBlob.CreateSnapshot-Methode ()

Creates a snapshot of the blob.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in microsoft.windowsazure.storageclient.dll)

'Usage
Dim instance As CloudBlob
Dim returnValue As CloudBlob

returnValue = instance.CreateSnapshot

public CloudBlob CreateSnapshot ()
public CloudBlob CreateSnapshot ()
public function CreateSnapshot () : CloudBlob

Rückgabewert

A blob snapshot.

static void CreateBlobSnapshot(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");

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

    //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.

noteHinweis
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.

noteHinweis
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.


Alle öffentlichen statischen (freigegebenen in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Entwicklungsplattformen

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 und Windows 2000

Zielplattformen

Community-Beiträge

Anzeigen:
© 2014 Microsoft