| title | Upload a VHD file to Azure DevTest Labs by using PowerShell |
|---|---|
| description | Walk through the steps to use PowerShell to upload a VHD file to a lab storage account in Azure DevTest Labs. |
| ms.topic | how-to |
| ms.author | rosemalcolm |
| author | RoseHJM |
| ms.date | 09/30/2023 |
| ms.custom | UpdateFrequency2 |
[!INCLUDE devtest-lab-upload-vhd-selector]
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.
- 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.
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.
:::image type="content" source="media/devtest-lab-upload-vhd-using-powershell/upload-image-powershell.png" alt-text="Screenshot that shows the link to upload a VHD by using PowerShell on the Custom image pane.":::
-
In Upload an image using PowerShell, select and copy the generated PowerShell script to use in the next section.
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
-LocalFilePathparameter 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
-LocalFilePathparameter.
The process of uploading a VHD file might be lengthy depending on the size of the VHD file and your connection speed.