Esporta (0) Stampa
Espandi tutto

Metodo CloudDrive.Mount

Mounts a Windows Azure drive and returns a drive letter for the drive on the local file system.

Spazio dei nomi: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.CloudDrive (in microsoft.windowsazure.clouddrive.dll)

Dim instance As CloudDrive
Dim cacheSize As Integer
Dim options As DriveMountOptions
Dim returnValue As String

returnValue = instance.Mount(cacheSize, options)

Public Function Mount ( _
	cacheSize As Integer, _
	options As DriveMountOptions _
) As String
public String Mount (
	int cacheSize, 
	DriveMountOptions options
public function Mount (
	cacheSize : int, 
	options : DriveMountOptions
) : String



The size of the optional write-through cache for this mounted drive. Set this parameter to 0 if you do not wish to specify a cache for the drive.


The set of DriveMountOptions for mounting the drive.

Valore restituito

The local files system path for the mounted drive, including the drive letter.

The following example creates and mounts a Windows Azure drive with no cache space allocated.

public void CreateAndMountDrive()
    // 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);

    // Get a reference to the page blob that will back the drive.
    CloudPageBlob pageBlob = container.GetPageBlobReference("myvhd");

    // Return a reference to the drive backed by the specified page blob. 
    CloudDrive drive = new CloudDrive(pageBlob.Uri, storageAccount.Credentials);

        // Create a 64 MB drive.

        // Mount the drive.
        string driveLetter = drive.Mount(0, DriveMountOptions.None);

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

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.

The specified cacheSize is dependent on the amount of remaining space in the cache directory as well as the amount of remaining local disk space. As a result, the resulting cache may not be equal to the amount you specify when calling this method.

Calling Mount mounts a Windows Azure drive within the role instance and returns a drive letter that may be used to access the drive.

The page blob must exist in the specified container before the drive can be mounted. Calling the Create method creates and formats a page blob as a fixed VHD with a single NTFS partition. Alternatively, you can upload your own VHD to a page blob, as long as it is fixed and formatted as a single NTFS partition, and mount the drive using that VHD.

You can mount up to 16 drives per role instance.

Note that if a non-zero value is to be specified for the cacheSize parameter, the cache for the role instance must first be initialized by calling the InitializeCache method.

A Windows Azure drive may be mounted as a writable drive, or as a read-only drive if it is created from a snapshot of a page blob. To create a writable drive, create a new instance of the CloudDrive object, specifying the desired URI for the page blob. Call the Create method to create and format the page blob, then call the Mount method to mount the drive.

To create a read-only drive, call the Snapshot method to create a new snapshot and return the snapshot's URI, then create a new instance of the CloudDrive object from the snapshot's URI and mount the drive.

When a role instance mounts a writable drive, it acquires an exclusive-write lease on the associated page blob that it retains as long as the drive is mounted. If the same role instance attempts to mount the drive a second time, the operation is ignored and the Mount method returns the local path to the existing drive.

Only one instance at a time may mount a writable drive and acquire its lease. Once the drive has been unmounted, another instance may mount the drive and successfully acquire its lease. A role instance can attempt to mount the drive and acquire the lease by calling Mount with the Force option specified. The Force option prevents the instance which currently has the lease on the drive from renewing the lease, and thus allows a second instance to acquire it.

Call Mount with the Force option specified only if your application requires that one role instance acquire the lease on the drive from another.

If a role instance mounts a read-only drive, there is no associated lease, as snapshots cannot be leased. Multiple role instances can mount and access the same read-only drive.

Calling Mount with the FixFileSystemErrors option specified runs the Windows CHKDSK utility on the drive once it is mounted, and attempts to fix file system errors.

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme di sviluppo

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

Piattaforme di destinazione

Aggiunte alla community

© 2014 Microsoft