Rediger

Del via


Create a VM from a specialized disk by using PowerShell

Applies to: ✔️ Windows VMs

Create a new VM by attaching an existing OS disk to a new VM. This option is useful if you have a VM that isn't working correctly. You can delete the VM and then reuse the disk to create a new VM.

Important

You can also use the VHD as a source to create an Azure Compute Gallery image. For more information, see Create an image definition and image version. Customers are encouraged to use Azure Compute Gallery as all new features like ARM64, Trusted Launch, and Confidential VM, are only supported through Azure Compute Gallery.  Creating an image instead of just attaching a disk means you can create multiple VMs from the same source disk.

When you use a specialized disk to create a new VM, the new VM retains the computer name of the original VM. Other computer-specific information (like the CMID) is also kept and, in some cases, this duplicate information could cause issues. When copying a VM, be aware of what types of computer-specific information your applications rely on.

We recommend that you limit the number of concurrent deployments to 20 VMs from a single VHD or snapshot.

Create a snapshot and then create a disk from the snapshot. This strategy allows you to keep the original VHD as a fallback:

  1. Open the Azure portal.
  2. In the search box, enter disks and then select Disks to display the list of available disks.
  3. Select the disk that you would like to use. The Disk page for that disk appears.
  4. From the menu at the top, select Create snapshot.
  5. Choose a Resource group for the snapshot. You can use either an existing resource group or create a new one.
  6. Enter a Name for the snapshot.
  7. For Snapshot type, choose Full.
  8. For Storage type, choose Standard HDD, Premium SSD, or Zone-redundant storage.
  9. When you're done, select Review + create to create the snapshot.
  10. After the snapshot has been created, select Home > Create a resource.
  11. In the search box, enter managed disk and then select Managed Disks from the list.
  12. On the Managed Disks page, select Create.
  13. Choose a Resource group for the disk. You can use either an existing resource group or create a new one. This selection will also be used as the resource group where you create the VM from the disk.
  14. For Region, you must select the same region where the snapshot is located.
  15. Enter a Name for the disk.
  16. In Source type, ensure Snapshot is selected.
  17. In the Source snapshot drop-down, select the snapshot you want to use.
  18. For Size, you can change the storage type and size as needed.
  19. Make any other adjustments as needed and then select Review + create to create the disk. Once validation passes, select Create.

After you have the disk that you want to use, you can create the VM in the portal:

  1. In the search box, enter disks and then select Disks to display the list of available disks.
  2. Select the disk that you would like to use. The Disk page for that disk opens.
  3. In the Essentials section, ensure that Disk state is listed as Unattached. If it isn't, you might need to either detach the disk from the VM or delete the VM to free up the disk.
  4. In the menu at the top of the page, select Create VM.
  5. On the Basics page for the new VM, enter a Virtual machine name and either select an existing Resource group or create a new one.
  6. For Size, select Change size to access the Size page.
  7. The disk name should be pre-filled in the Image section.
  8. On the Disks page, you may notice that the OS Disk Type cannot be changed. This preselected value is configured at the point of Snapshot or VHD creation and will carry over to the new VM. If you need to modify disk type take a new snapshot from an existing VM or disk.
  9. On the Networking page, you can either let the portal create all new resources or you can select an existing Virtual network and Network security group. The portal always creates a new network interface and public IP address for the new VM.
  10. On the Management page, make any changes to the monitoring options.
  11. On the Guest config page, add any extensions as needed.
  12. When you're done, select Review + create.
  13. If the VM configuration passes validation, select Create to start the deployment.

Next steps Learn more about Azure Compute Gallery.