EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,
Det här ämnet har inte bedömts ännu - Bedöm det här ämnet

Create and Reference a Snapshot

A snapshot is a read-only blob, and like writable blobs, it is represented by a CloudBlob object. To create a snapshot, call the CreateSnapshot method on a blob:

static void CreateSnapshot(CloudBlobClient blobClient)
{
    // Reference a container 
    CloudBlobContainer container = new CloudBlobContainer("mycontainer", blobClient);
    container.CreateIfNotExist();

    // Create a blob in the container.
    CloudBlob blob = container.GetBlobReference("myblob.txt");
    blob.UploadText("some text");

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

    // Write out the snapshot URI and snapshot time.
    Console.WriteLine(snapshot.Uri);
    Console.WriteLine(snapshot.SnapshotTime);
}

To reference an existing snapshot, use one of the CloudBlob constructors that takes the snapshot time as a parameter:

static void ReferenceBlobSnapshot(CloudBlobClient blobClient)
{
    //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 and timestamp.
    Console.WriteLine(snapshot2.Uri);
    Console.WriteLine(snapshot2.SnapshotTime);
} 

See Also

Var detta till hjälp?
(1500 tecken kvar)

Gruppinnehåll

Lägg till
© 2013 Microsoft. Med ensamrätt.
facebook page visit twitter rss feed newsletter