When you have VMs in Azure that are built outside of an Azure Vnet and you want to have that VM talking to another VM, or you need to set security boundaries, you will need to migrate this VM into an Vnet. In Azure (or even PowerShell), there is no option to link an existing networkless VM to a new or existing Vnet, this post is about how to do that.
First step is to log into the old or new portal and select the VM you wish to move
Stop the VM and select Delete,
fill in the name of the VM and pay attention here as it is crucial that you DO NOT select the disk(s) in the wizard
Old portal:
Now that the VM is deleted, we also need to remove the ‘Cloud Service’.
please note that when you have a VIP, you will be assigned a new one later.
Now we will create a new VM based upon the disks that are still in our storage account.
At this time of writing, following action is not possible in the new portal, hence, we need to return to the old one.
Select New VM, select ‘From Gallery’ and go to ‘My Disks’ and select the disk from the deleted VM:
Give the VM his name back and select the appropriate size of your VM:
Select New or existing ‘Cloud Service’, Region and ‘Availability Set’
In the last wizard page, select any extensions if required.
Add additional Data disks to your VM if needed
Et voila, your VM is now available in the VNet of your choice.