If you have existing VM’s you are running on-site, it’s possible to upload them to Azure and configure them as disks or images. Disks can be attached to VM’s which then allow you to effectively migrate your on premise VM’s to the Azure cloud. With Azure Images, you can customize operating systems with your preferred configurations, SysPrep them and then upload to Azure to provision multiple VM’s from.
You should bare the following things in mind when you are uploading existing virtual hard disks to Azure
· Azure only supported VHD files and not VHDX files (which is likely to change)
· Azure only supported fixed size VHD files
· Azure Operating System disks can be a maximum of 127GB’s
· Azure Data disks can be a maximum of 1TB
To upload VM’s to Azure you must have an Azure Storage account in place to act as a target for the VHD files. You can provision a new Storage Account by clicking New, Data Services, Storage and Quick Create. The URL you choose must be globally unique, also choose a region which is closest to your physical location. There are four options for Replication, I have chosen Geo-Redundant. With Geo-Redundant there is 6 copies of the data maintained, 3 replica’s in your current region and 3 replica’s in another region. Further information on Storage Account options can be found here
Once the Storage Account has been created, now you must make an Azure PowerShell connection from your device, use the following commands with your variables to upload an already existing VHD file from the computer you have made the PowerShell connection from. The first three statements are setting variables that are then called by the Add-AzureVHD statement.
$storage = “rbetts92”
$sourcePath = “C:\Users\R Betts\Desktop\AzureExample.vhd”
Add-AzureVHD –Destination $storagePath –LocalFilePath $sourcePath
You get a graphical representation of the VHD being uploaded to Azure, an MD5 hash is generate as a checksum to confirm the VHD is not corrupt when it reaches Azure.
When it completes you will be presented by confirmation screen with a summary of the file upload.
If you return to the Azure Management Portal, and browse to your Storage Account you should see the VHD that has just been uploaded to the Storage Account.
The next step is to change the disk type to an Azure Disk, this is different from an Azure Image, which would have to be SysPrep’d. Use the following PowerShell command to tag/label the uploaded disk as an Azure disk. The first two statements are setting variables.
$diskName = “AzureDisk”
$label = “MyAzureDisk”
Add-AzureDisk –DiskName $diskName –Label $label –MediaLocation $storagePath –OS Linux
Now you can create a new Azure Virtual Machine from your uploaded image, use the Create New VM wizard, but instead of clicking on a pre-define click My Disks from the list on the left hand side.
Select the new VHD and run through the wizard to provision a machine from an existing hard disk.
As this VM I uploaded is Linux and has the Azure Linux Tools installed, I click on The VM Agent that Supports the Extensions is Already Installed.
Now that the disk is attached to an Azure VM, the next step that is required is to create endpoints to allow remote connections to the machine, for example SSH etc.