Muokkaa

Jaa


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

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:

  1. Sign in to the Azure portal.

  2. Select All resources, and then select your lab.

  3. In the lab menu under Settings, select Configuration and policies.

  4. In Activity log, in the resource menu under Virtual machine bases, select Custom images.

  5. In Custom images, select Add.

  6. In Custom image, under VHD, select the Upload an image using PowerShell link.

    Screenshot that shows the link to upload a VHD by using PowerShell on the Custom image pane.

  7. 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:

  1. In a text editor, paste the generated PowerShell script you copied from the Azure portal.

  2. Modify the -LocalFilePath parameter of the Add-AZVHD cmdlet to point to the location of the VHD file you want to upload.

  3. 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.

Next steps