匯出 (0) 列印
全部展開
本主題尚未接受評分 - 為這個主題評分

CloudBlob.CreateSnapshot 方法 (BlobRequestOptions)

Creates a snapshot of the blob.

命名空間: Microsoft.WindowsAzure.StorageClient
組件: Microsoft.WindowsAzure.StorageClient (在 microsoft.windowsazure.storageclient.dll 中)
'用途
Dim instance As CloudBlob
Dim options As BlobRequestOptions
Dim returnValue As CloudBlob

returnValue = instance.CreateSnapshot(options)
public CloudBlob CreateSnapshot (
	BlobRequestOptions options
)
public CloudBlob CreateSnapshot (
	BlobRequestOptions options
)
public function CreateSnapshot (
	options : BlobRequestOptions
) : CloudBlob

參數

options

An object that specifies any additional options for the request.

傳回值

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.

note注意事項
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.

note注意事項
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.


任何這個類型的公用靜態 (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。 並非所有的執行個體成員都是安全執行緒。

開發平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003、Windows Server 2008 和 Windows 2000

目標平台

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

顯示:
© 2014 Microsoft. 著作權所有,並保留一切權利。