Upload a VHD file to a lab storage account by using PowerShell
In this article, learn how to use PowerShell 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.
Prerequisites
- Download and install the latest version of PowerShell.
To upload a VHD file to a lab storage account by using PowerShell, first, get the lab storage account name via the Azure portal. Then, use a PowerShell cmdlet 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, select and copy the generated PowerShell script to use in the next section.
Upload a VHD file
To upload a VHD file by using PowerShell:
In a text editor, paste the generated PowerShell script you copied from the Azure portal.
Modify the
-LocalFilePath
parameter of the Add-AZVHD cmdlet to point to the location of the VHD file you want to upload.At a PowerShell command prompt, run the Add-AZVHD cmdlet with the modified
-LocalFilePath
parameter.
The process of uploading a VHD file might be lengthy depending on the size of the VHD file and your connection speed.