VENTAS: 1-800-867-1389

CloudDrive.Snapshot (Método)

Creates a snapshot of the page blob associated with this Windows Azure drive.

Espacio de nombres: Microsoft.WindowsAzure.StorageClient
Ensamblado: Microsoft.WindowsAzure.CloudDrive (en microsoft.windowsazure.clouddrive.dll)

Dim instance As CloudDrive
Dim returnValue As Uri

returnValue = instance.Snapshot

Public Function Snapshot As Uri
public Uri Snapshot ()
public function Snapshot () : Uri

Valor devuelto

Returns a URI to the newly created snapshot.

The following code example creates a writable drive and writes some data to it, then takes a snapshot of the drive and mounts the snapshot as a read-only drive.

public void MountDriveAndSnapshot()
    // Get a reference to the local resource.
    LocalResource localResource = RoleEnvironment.GetLocalResource("LocalDriveCache");

    // Initialize the drive cache.
    CloudDrive.InitializeCache(localResource.RootPath, localResource.MaximumSizeInMegabytes);

    // Use the storage emulator.
    CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;

    // Create the Blob service client.
    CloudBlobClient client = storageAccount.CreateCloudBlobClient();

    // Create the container for the drive if it does not already exist.
    CloudBlobContainer container = new CloudBlobContainer("mydrives", client);

    // Create and mount a drive, allocating some cache space.
    CloudDrive drive1 = new CloudDrive(container.GetPageBlobReference("myvhd" + Path.GetRandomFileName()).Uri, storageAccount.Credentials);
    string driveLetter = drive1.Mount((int)Math.Round((double)localResource.MaximumSizeInMegabytes / 2), DriveMountOptions.None);

    // Write to the drive.
    for (int i = 0; i < 1000; i++)
        System.IO.File.WriteAllText(driveLetter + "\\" + i.ToString() + ".txt", "Test");

    // Snapshot the drive.
    Uri snapshotUri = drive1.Snapshot();

    // Mount a drive using the snapshot.
    CloudDrive drive2 = new CloudDrive(snapshotUri, storageAccount.Credentials);
    driveLetter = drive2.Mount((int)Math.Round((double)localResource.MaximumSizeInMegabytes / 2), DriveMountOptions.None);

    // List each drive letter and associated page blob.
    foreach (var item in CloudDrive.GetMountedDrives())
        System.Diagnostics.Debug.WriteLine("Drive letter: " + item.Key);
        System.Diagnostics.Debug.WriteLine("Page blob URI: " + item.Value);

A snapshot is a read-only copy of a blob taken at a given point in time. Taking a snapshot of the page blob that backs a Windows Azure drive is a useful way to back up the drive.

A snapshot of a blob has the same name as the base blob from which the snapshot is taken, with a DateTime value appended to indicate the time at which the snapshot was taken. For example, if the page blob URI is, the snapshot URI will be similar to!2011-03-09T01:42:34.9360000Z.

You can use a snapshot to create and mount a read-only drive.

Each time you call the Snapshot method, a new snapshot is created. Snapshots persist unless they are explicitly deleted.

Note that when you create a snapshot of a page blob, you are not charged for pages in the snapshot as long as the base page blob and the snapshot remain the same. When a page in the base blob is updated, that page diverges from the page that exists in the snapshot, and you are subsequently charged for both unique pages. To avoid unexpected charges, delete unnecessary snapshots after updating the base blob.

Cualquier miembro estático público (Shared en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Plataformas de desarrollo

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

Plataformas de destino

¿Te ha resultado útil?
(Caracteres restantes: 1500)
Gracias por sus comentarios

Adiciones de comunidad

© 2014 Microsoft