Search This Blog

Friday, February 21, 2014

Upload a Virtual Machine to Windows Azure

 

Let have a look on how to upload your existing virtual machine to Windows Azure. This process may come handy when you want to migrate existing virtual disk running on Hyper-V to Windows Azure.

To do so , please read below pre-requisite

1. Assign a person as Service Administrator or Co-Administrator at Windows Azure Portal. Go to Settings | Administrator. The person who are going to upload the VHD must be Service Administrator or Co-Administrator role.

SNAGHTML1e1b93a

2. Require a management certificate. –Certificate can be self signed. Upload a certificate at Setting | Management Certificate. Make sure this certificate is at the machine that you plan to upload a VHD from.

image

3. Get Storage Account name url. You can get Storage Account URL from Storage | Storage Account Name | Containers

image

4. Use Windows Azure Power shell and use the command Add-AzureVHD to upload vhd. Before you upload, do take a few second to look into the this requirement of your virtual disk:-

  • Must in VHD virtual disk. Use Hyper-V Manager or “Convert-VHD” to convert VHDX to VHD
  • Only fixed disk. When upload a virtual disk, the disk can be in dynamic disk. Windows Azure will convert to fixed disk. Do not upload differencing disk as it is unsupported.
  • Allow RDP Access on your virtual disk so you can remote into the vm once the VHD has been uploaded.
  • Must in sysprep state and under supported Windows operating system stored in a .vhd file:-
    • Windows Server 2008 R2 with SP1 (all editions)
    • Windows Server 2012 (All editions)
  • Configure default subscription on which upload VHD to use
Import-AzurePublishSettingsFile ‘your subscription settings’

image

  • Configure default storage account on where to upload the VHD. You can get subscription name by using the command “Get-AzureSubscription”. To get storage container name, refer to step 3.
Set-AzureSubscription –SubscriptionName “Converted Windows Azure MSDN – Visual Studio Premium” –CurrentStorageAccountName “portalvhdscqm83jwmy4nzq”

image

image

Lastly use Add-AzureVHD command.

$sourcevhd= “C : \AzureWin2012R2Std.vhd”
$destinationvhd = “http://portalvhdscqm83jwmy4nzq.blob.core.windows.net/vhds/AzureWin2012R2Std.vhd”

Add-AzureVHD –LocalfilePath $sourcevhd –Destination $destinationvhd

SNAGHTML51f812d

The above diagram showed it has uploaded the dynamic disk to Azure Storage and convert to fixed disk. You can verify and check on Windows Azure Portal. Our dynamic disk is around 8 GB and has converted to fixed disk- 80GB.

SNAGHTML521949c

Last but not least after upload your VHD, you need to add an image to your list of custom images. From Management Portal, under All Items , click Virtual Machines | Images | Click Create. Enter the name and make sure select “I have run sysprep on the virtual machine associated with this VHD” to acknowledge that you generalized the operating system.

image

Now you can select your custom image from the Gallery and provision a virtual machine using own pre-installed operating system.

image