|
1 | 1 | ---
|
2 |
| -title: How to bring a Windows custom image from your physical lab environment |
3 |
| -description: Describes how to bring a Windows custom image from your physical lab environment. |
4 |
| -ms.date: 07/27/2021 |
| 2 | +title: Import a Windows image from a physical lab |
| 3 | +titleSuffix: Azure Lab Services |
| 4 | +description: Learn how to import a Windows custom image from your physical lab environment into Azure Lab Services. |
| 5 | +services: lab-services |
| 6 | +ms.service: lab-services |
| 7 | +author: ntrogh |
| 8 | +ms.author: nicktrog |
| 9 | +ms.date: 04/24/2023 |
5 | 10 | ms.topic: how-to
|
6 | 11 | ---
|
7 | 12 |
|
8 |
| -# Bring a Windows custom image from a physical lab environment |
| 13 | +# Bring a Windows custom image from a physical lab environment to Azure Lab Services |
9 | 14 |
|
10 |
| -The steps in this article show how to import a custom image that starts from your physical lab environment. With this approach, you create a VHD from your physical environment and import the VHD into a compute gallery so that it can be used within Lab Services. Before you use this approach for creating a custom image, read the article [Recommended approaches for creating custom images](approaches-for-custom-image-creation.md) to decide the best approach for your scenario. |
| 15 | +This article describes how to import a custom image from a physical lab environment for creating a lab in Azure Lab Services. |
| 16 | + |
| 17 | +The import process consists of the following steps: |
| 18 | + |
| 19 | +1. Create a virtual hard drive (VHD) from your physical environment |
| 20 | +1. Import the VHD into an Azure compute gallery |
| 21 | +1. [Attach the compute gallery to your lab plan](/azure/lab-services/how-to-attach-detach-shared-image-gallery) |
| 22 | +1. Create a lab based by using the image in the compute gallery |
| 23 | + |
| 24 | +Before you import an image from a physical lab, learn more about [recommended approaches for creating custom images](approaches-for-custom-image-creation.md). |
11 | 25 |
|
12 | 26 | ## Prerequisites
|
13 | 27 |
|
14 |
| -You will need permission to create an [Azure managed disk](../virtual-machines/managed-disks-overview.md) in your school's Azure subscription to complete the steps in this article. |
| 28 | +- Your Azure account has permission to create an [Azure managed disk](/azure/virtual-machines/managed-disks-overview.md). Learn about the [Azure RBAC roles you need to create a managed disk](/azure/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell#assign-rbac-role). |
15 | 29 |
|
16 |
| -When moving images from a physical lab environment to Lab Services, you should restructure each image so that it only includes software needed for a lab's class. For more information, read the [Moving from a Physical Lab to Azure Lab Services](https://techcommunity.microsoft.com/t5/azure-lab-services/moving-from-a-physical-lab-to-azure-lab-services/ba-p/1654931) blog post. |
| 30 | +- Restructure each virtual machine image so that it only includes the software that is needed for a lab's class. Learn more about [moving from a Physical Lab to Azure Lab Services](./concept-migrating-physical-labs.md). |
17 | 31 |
|
18 | 32 | ## Prepare a custom image using Hyper-V Manager
|
19 | 33 |
|
20 |
| -The following steps show how to create a Windows image from a Windows Hyper-V virtual machine (VM) using Hyper-V Manager: |
| 34 | +First, create a virtual hard disk (VHD) for the physical environment. The following steps describe how to create a VHD from a Windows Hyper-V virtual machine (VM) by using Hyper-V Manager: |
| 35 | + |
| 36 | +1. Create a Hyper-V virtual machine in your physical lab environment based on your custom image. |
21 | 37 |
|
22 |
| -1. Start with a Hyper-V VM in your physical lab environment that has been created from your image. Read the article on [how to create a virtual machine in Hyper-V](/windows-server/virtualization/hyper-v/get-started/create-a-virtual-machine-in-hyper-v) for more information. |
23 | 38 | - The VM must be created as a **Generation 1** VM.
|
24 | 39 | - Use the **Default Switch** network configuration option to allow the VM to connect to the internet.
|
25 |
| - - The VM's virtual disk must be a fixed size VHD. The disk size must *not* be greater than 128 GB. When you create the VM, enter the size of the disk as shown in the below image. |
| 40 | + - The VM's virtual disk must be a fixed size VHD. The disk size must *not* be greater than 128 GB. When you create the VM, enter the size of the disk as shown in the below image. |
| 41 | + |
| 42 | + :::image type="content" source="./media/upload-custom-image-shared-image-gallery/connect-virtual-hard-disk.png" alt-text="Screenshot of the Connect virtual hard disk screen in Hyper-V Manager, highlighting the option for fixed disk size."::: |
| 43 | + |
| 44 | + Azure Lab Services does *not* support images with disk size greater than 128 GB. |
| 45 | + |
| 46 | + Learn more about [how to create a virtual machine in Hyper-V](/windows-server/virtualization/hyper-v/get-started/create-a-virtual-machine-in-hyper-v). |
| 47 | + |
| 48 | +1. Connect to the Hyper-V VM and [prepare it for Azure](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md) by following these steps: |
| 49 | + |
| 50 | + 1. [Set Windows configurations for Azure](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#set-windows-configurations-for-azure). |
| 51 | + 1. [Check the Windows services that are needed to ensure VM connectivity](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#check-the-windows-services). |
| 52 | + 1. [Update remote desktop registry settings](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#update-remote-desktop-registry-settings). |
| 53 | + 1. [Configure Windows Firewall rules](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#configure-windows-firewall-rules). |
| 54 | + 1. [Install Windows updates](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md). |
| 55 | + 1. [Install Azure VM Agent and extra configuration](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#complete-the-recommended-configurations) |
| 56 | + |
| 57 | + You can upload either specialized or generalized images to a compute gallery and use them to create labs. The previous steps create a specialized image. If you need a generalized image, you also have to [run SysPrep](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#determine-when-to-use-sysprep). |
26 | 58 |
|
27 |
| - :::image type="content" source="./media/upload-custom-image-shared-image-gallery/connect-virtual-hard-disk.png" alt-text="Connect virtual hard disk"::: |
| 59 | + You should create a specialized image if you want to maintain machine-specific information and user profiles. For more information about the differences between generalized and specialized images, see [Generalized and specialized images](/azure/virtual-machines/shared-image-galleries.md#generalized-and-specialized-images). |
28 | 60 |
|
29 |
| - Images with disk size greater than 128 GB are *not* supported by Lab Services. |
| 61 | +1. Convert the default Hyper-V `VHDX` hard disk file format to `VHD`: |
30 | 62 |
|
31 |
| -1. Connect to the Hyper-V VM and [prepare it for Azure](../virtual-machines/windows/prepare-for-upload-vhd-image.md) by following these steps: |
32 |
| - 1. [Set Windows configurations for Azure](../virtual-machines/windows/prepare-for-upload-vhd-image.md#set-windows-configurations-for-azure). |
33 |
| - 1. [Check the Windows Services that are needed to ensure VM connectivity](../virtual-machines/windows/prepare-for-upload-vhd-image.md#check-the-windows-services). |
34 |
| - 1. [Update remote desktop registry settings](../virtual-machines/windows/prepare-for-upload-vhd-image.md#update-remote-desktop-registry-settings). |
35 |
| - 1. [Configure Windows Firewall rules](../virtual-machines/windows/prepare-for-upload-vhd-image.md#configure-windows-firewall-rules). |
36 |
| - 1. [Install Windows Updates](../virtual-machines/windows/prepare-for-upload-vhd-image.md). |
37 |
| - 1. [Install Azure VM Agent and additional configuration as shown here](../virtual-machines/windows/prepare-for-upload-vhd-image.md#complete-the-recommended-configurations) |
| 63 | + 1. In Hyper-V Manager, select the virtual machine, and then select **Action** > **Edit Disk**. |
38 | 64 |
|
39 |
| - You can upload either specialized or generalized images to a compute gallery and use them to create labs. The steps above will create a specialized image. If you need to instead create a generalized image, you also will need to [run SysPrep](../virtual-machines/windows/prepare-for-upload-vhd-image.md#determine-when-to-use-sysprep). |
| 65 | + 1. Next, select **Convert** to convert the disk from a VHDX to a VHD. |
40 | 66 |
|
41 |
| - You should create a specialized image if you want to maintain machine-specific information and user profiles. For more information about the differences between generalized and specialized images, see [Generalized and specialized images](../virtual-machines/shared-image-galleries.md#generalized-and-specialized-images). |
| 67 | + :::image type="content" source="./media/upload-custom-image-shared-image-gallery/choose-action.png" alt-text="Screenshot that shows the Choose Action screen when editing a virtual machine in Hyper-V Manager."::: |
42 | 68 |
|
43 |
| -1. Since **Hyper-V** creates a **VHDX** file by default, you need to convert this to a VHD file. |
44 |
| - 1. Navigate to **Hyper-V Manager** -> **Action** -> **Edit Disk**. |
45 |
| - 1. Next, **Convert** the disk from a VHDX to a VHD. |
46 |
| - - If you expand the disk size, make sure that you do *not* exceed 128 GB. |
47 |
| - :::image type="content" source="./media/upload-custom-image-shared-image-gallery/choose-action.png" alt-text="Choose action"::: |
| 69 | + If you expand the disk size, make sure that you do *not* exceed 128 GB. |
48 | 70 |
|
49 |
| - For more information, read the article that shows how to [convert the virtual disk to a fixed size VHD](../virtual-machines/windows/prepare-for-upload-vhd-image.md#convert-the-virtual-disk-to-a-fixed-size-vhd). |
| 71 | + Learn more about how to [convert a virtual disk to a fixed size VHD](/azure/virtual-machines/windows/prepare-for-upload-vhd-image.md#convert-the-virtual-disk-to-a-fixed-size-vhd). |
50 | 72 |
|
51 |
| -To help with resizing the VHD and converting to a VHDX, you can also use the following PowerShell cmdlets: |
| 73 | +Alternately, you can resize and convert a VHDX by using PowerShell: |
52 | 74 |
|
53 | 75 | - [Resize-VHD](/powershell/module/hyper-v/resize-vhd)
|
54 | 76 | - [Convert-VHD](/powershell/module/hyper-v/convert-vhd)
|
55 | 77 |
|
56 | 78 | ## Upload the custom image to a compute gallery
|
57 | 79 |
|
| 80 | +Next, you upload the VHD file from your physical environment to an Azure compute gallery. |
| 81 | + |
58 | 82 | 1. Upload the VHD to Azure to create a managed disk.
|
59 |
| - 1. You can use either Storage Explorer or AzCopy from the command line, as shown in [Upload a VHD to Azure or copy a managed disk to another region](../virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell.md). |
60 | 83 |
|
61 |
| - 1. After you've uploaded the VHD, you should now have a managed disk that you can see in the Azure portal. |
62 |
| - If your machine goes to sleep or locks, the upload process may get interrupted and fail. Also, make sure after AzCopy completes, that you revoke the SAS access to the disk. Otherwise, when you attempt to create an image from the disk, you will see an error: **Operation 'Create Image' is not supported with disk 'your disk name' in state 'Active Upload'. Error Code: OperationNotAllowed** |
| 84 | + You can use either Storage Explorer or AzCopy from the command line, as shown in [Upload a VHD to Azure or copy a managed disk to another region](/azure/virtual-machines/windows/disks-upload-vhd-to-managed-disk-powershell.md). |
| 85 | + |
| 86 | + If your machine goes to sleep or locks, the upload process may get interrupted and fail. Also, make sure after AzCopy completes, that you revoke the SAS access to the disk. Otherwise, when you attempt to create an image from the disk, you encounter an error: **Operation 'Create Image' is not supported with disk 'your disk name' in state 'Active Upload'. Error Code: OperationNotAllowed**. |
| 87 | + |
| 88 | + After you've uploaded the VHD, you should now have a managed disk that you can see in the Azure portal. |
63 | 89 |
|
64 | 90 | The Azure portal's **Size+Performance** tab for the managed disk allows you to change your disk size. As mentioned before, the size must *not* be greater than 128 GB.
|
65 | 91 |
|
66 |
| -1. In a compute gallery, create an image definition and version: |
67 |
| - 1. [Create an image definition](../virtual-machines/image-version.md). |
| 92 | +1. In a compute gallery, follow these steps to [create an image definition and version](/azure/virtual-machines/image-version.md). |
| 93 | + |
68 | 94 | - Choose **Gen 1** for the **VM generation**.
|
69 |
| - - Choose whether you are creating a **specialized** or **generalized** image for the **Operating system state**. |
70 | 95 |
|
71 |
| - For more information about the values you can specify for an image definition, see [Image definitions](../virtual-machines/shared-image-galleries.md#image-definitions). |
| 96 | + - Choose whether you're creating a **specialized** or **generalized** image for the **Operating system state** |
| 97 | + |
| 98 | + For more information about the values you can specify for an image definition, see [Image definitions](/azure/virtual-machines/shared-image-galleries.md#image-definitions). |
72 | 99 |
|
73 | 100 | You can also choose to use an existing image definition and create a new version for your custom image.
|
74 | 101 |
|
75 |
| -1. [Create an image version](../virtual-machines/image-version.md). |
76 |
| - - The **Version number** property uses the following format: *MajorVersion.MinorVersion.Patch*. When you use Lab Services to create a lab and choose a custom image, the most recent version of the image is automatically used. The most recent version is chosen based on the highest value of MajorVersion, then MinorVersion, then Patch. |
| 102 | +1. Follow these steps to [create an image version](/azure/virtual-machines/image-version.md). |
| 103 | + |
| 104 | + - The **Version number** property uses the following format: *MajorVersion.MinorVersion.Patch*. When you use Azure Lab Services to create a lab and choose a custom image, the most recent version of the image is automatically used. The most recent version is chosen based on the highest value of MajorVersion, then MinorVersion, then Patch. |
| 105 | + |
77 | 106 | - For the **Source**, choose **Disks and/or snapshots** from the drop-down list.
|
| 107 | + |
78 | 108 | - For the **OS disk** property, choose the disk that you created in previous steps.
|
79 | 109 |
|
80 |
| - For more information about the values you can specify for an image definition, see [Image versions](../virtual-machines/shared-image-galleries.md#image-versions). |
| 110 | + For more information about the values you can specify for an image definition, see [Image versions](/azure/virtual-machines/shared-image-galleries.md#image-versions). |
81 | 111 |
|
82 | 112 | ## Create a lab
|
83 | 113 |
|
84 |
| -1. [Create the lab](tutorial-setup-lab.md) in Lab Services and select the custom image from the compute gallery. |
| 114 | +Now that the custom image is available in an Azure compute gallery, you can create a lab by using the image. |
| 115 | + |
| 116 | +1. [Attach the compute gallery to your lab plan](./how-to-attach-detach-shared-image-gallery.md) |
| 117 | + |
| 118 | +1. [Create the lab](tutorial-setup-lab.md) and select the custom image from the compute gallery. |
85 | 119 |
|
86 |
| - If you expanded the disk *after* the OS was installed on the original Hyper-V VM, you may also need to extend the C drive in Windows to use the unallocated disk space: |
87 |
| - - Log into the lab's template VM and follow steps similar to what is shown in [Extend a basic volume](/windows-server/storage/disk-management/extend-a-basic-volume). |
| 120 | + If you expanded the disk *after* the OS was installed on the original Hyper-V VM, you may also need to extend the C drive in Windows to use the unallocated disk space. Log into the lab's template VM and follow these steps to [extend a basic volume](/windows-server/storage/disk-management/extend-a-basic-volume). |
88 | 121 |
|
89 | 122 | ## Next steps
|
90 | 123 |
|
91 |
| -- [Azure Compute Gallery overview](../virtual-machines/shared-image-galleries.md) |
92 | 124 | - [Attach or detach a compute gallery](how-to-attach-detach-shared-image-gallery.md)
|
93 | 125 | - [Use a compute gallery](how-to-use-shared-image-gallery.md)
|
| 126 | +- [Azure Compute Gallery overview](/azure/virtual-machines/shared-image-galleries.md) |
0 commit comments