Journey to ARM–Part IV – Creating a VM from an existing VHD

In my last blog, I have showed you how to copy the storage form your previous Classic storage account to brand new and shinny one. Now all you supposedly need is to create a new VM using that VHD.

So, a few assumptions before we go down to the needy-greedy:

– I already have a VNET to connect my VM to:

– You know the name of the VHD the VM is going to use

The script starts by setting some variables:

image

Then I get some VNET and subnet information:

image

Creates the NIC.

IMPORTANT NOTE! Make sure you don’t name your nic just ‘nic’ like I did on my first try.. You may have multiple nics in side the same resource group and you won’t know which one is which.

image

Then create the VM:

image

Make sure you get rid of the previous one in the classic model.

Find the final script here.

Hope this helps!