(0) exportieren Drucken
Alle erweitern

CloudDrive.Create-Methode

Creates a single-partition, NTFS-formatted Virtual Hard Disk (VHD) page blob to back the Windows Azure drive.

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

'Usage
Dim instance As CloudDrive
Dim sizeInMB As Integer

instance.Create(sizeInMB)

public void Create (
	int sizeInMB
)
public void Create (
	int sizeInMB
)
public function Create (
	sizeInMB : int
)

Parameter

sizeInMB

The size of the drive to create. The minimum size permitted is 16 MB. The maximum size permitted is 1 TB (the maximum size permitted for a page blob).

The following example creates and mounts a Windows Azure drive.


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);
    container.CreateIfNotExist();

    // 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);

    try
    {
        // Create a 64 MB drive.
        drive.Create(64);

        // 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)
    {
        System.Diagnostics.Debug.WriteLine(e.Message);
    }
}

The Create method creates a page blob at the location specified when the reference to the CloudDrive object was created. The container for the page blob must exist before you call the Create method.

noteHinweis
If the blob exists, the Create method will fail with a CloudDriveException. To prevent your role from recycling, ensure that you handle this exception properly and do not create a drive that already exists.

To mount a drive using an existing blob or snapshot, create a reference to a CloudDrive object using the URI to the existing blob, then call the Mount method without calling Create.

The Windows Azure drive is created as a fixed VHD within the page blob. Note that the drive format requires some space, so you will not have access to the full amount of space that you allocate for the drive.

noteHinweis
The Windows Azure development environment provides a simulation of a Windows Azure drive which does not rely on the Windows Azure storage emulator. If your code is running in the development environment, you will not see an actual page blob created in the local Blob service.


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

Microsoft führt eine Onlineumfrage durch, um Ihre Meinung zur MSDN-Website zu erfahren. Wenn Sie sich zur Teilnahme entscheiden, wird Ihnen die Onlineumfrage angezeigt, sobald Sie die MSDN-Website verlassen.

Möchten Sie an der Umfrage teilnehmen?
Anzeigen:
© 2014 Microsoft