How do you create Azure VM from image with unmanaged disk?

I have a Datacenter 2016 server with unmanaged disk. I need to be able to replicate this VM and continue using an unmanaged disk.

Do I need to provision the VM i want to replicate? Or can I just use the VHD in storage to create a new VM?

Here is my powershell script so far. Note that I tried to provision a VM

New-AzVm `
    -ResourceGroupName "myResource" `
    -Name "myVM" `
    -ImageName "" ` //IS THIS WHERE YOU WOULD PUT A VHD? 
    -Location "West US 2" `
    -VirtualNetworkName "my-vnet" `
    -SubnetName "default" `
    -SecurityGroupName "myvmNSG" `
    -OpenPorts 3389, 80, 443

Solution 1:

Found it!

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sa-create-vm-specialized

The most important part:

$osDiskUri = "https://myStorageAccount.blob.core.windows.net/myContainer/myOsDisk.vhd"

Basically, you need to reference the blob storage where the VHD resides using its URI; have a look at the page for the complete script.

Of course, you can't attach the existing disk to a new VM; you need to make a copy of it. And, since it's unmanaged, this means you'll need to perform a blob copy between storage accounts. This should help:

https://docs.microsoft.com/it-it/azure/storage/common/storage-use-azcopy-blobs https://docs.microsoft.com/it-it/azure/storage/common/storage-use-azcopy-blobs#copy-blobs-between-storage-accounts