Upload a VHD file to a lab storage account by using AzCopy
In this article, learn how to use the AzCopy command-line utility to upload a VHD file to a lab storage account in Azure DevTest Labs. After you upload your VHD file, you can create a custom image from the uploaded VHD file and use the image to provision a virtual machine.
For more information about disks and VHDs in Azure, see Introduction to managed disks.
AzCopy is a Windows-only command-line utility.
- Download and install the latest version of AzCopy.
To upload a VHD file to a lab storage account by using AzCopy, first, get the lab storage account name via the Azure portal. Then, use AzCopy to upload the file.
Get the lab storage account name
To get the name of the lab storage account:
Sign in to the Azure portal.
Select All resources, and then select your lab.
In the lab menu under Settings, select Configuration and policies.
In Activity log, in the resource menu under Virtual machine bases, select Custom images.
In Custom images, select Add.
In Custom image, under VHD, select the Upload an image using PowerShell link.
In Upload an image using PowerShell, scroll right to see a call to the Add-AzureRmVhd cmdlet.
-Destinationparameter contains the URI for a blob container in the following format:
Copy the storage account URI to use in the next section.
Upload a VHD file
To upload a VHD file by using AzCopy:
In Windows, open a Command Prompt window and go to the AzCopy installation directory.
By default, AzCopy is installed in ProgramFiles(x86)\Microsoft SDKs\Azure\AzCopy.
Optionally, you can add the AzCopy installation location to your system path.
At the command prompt, run the following command. Use the storage account key and blob container URI you copied from the Azure portal. The value for
vhdFileNamemust be in quotes.
AzCopy /Source:<sourceDirectory> /Dest:<blobContainerUri> /DestKey:<storageAccountKey> /Pattern:"<vhdFileName>" /BlobType:page
The process of uploading a VHD file might be lengthy depending on the size of the VHD file and your connection speed.
Automate uploading VHD files
To automate uploading VHD files to create custom images, use AzCopy to copy or upload VHD files to the storage account that's associated with the lab.
To find the destination storage account that's associated with your lab:
- Sign in to the Azure portal.
- On the left menu, select Resource Groups.
- Find and select the resource group that's associated with your lab.
- Under Overview, select one of the storage accounts.
- Select Blobs.
- Look for uploads in the list. If none exists, return to step 4 and try another storage account.
- Use the URL as the destination in your AzCopy command.