In my previous blog I covered a small introduction about windows Azure, and as we discussed Windows Azure has 3 roles as web role, worker role and VM role. VM role is the new role and till now still under Beta program. To be able to test this new role you have to upload a VHD to Azure. The base VHD acts as the initial template for the VM Role instances that are created in Windows Azure. The base VHD contains the operating system, any operating system customizations, and your applications.

clip_image001

Request access for VM Role

1- Go to https://windows.azure.com/ log in with your live ID.

2- Select home then Beta programs.

3- Select the program check box and Apply for Access.

4- It may take from 1 day up to a week to get approval for access.

clip_image003

Extend visual studio to support VM role

1- Create a new text.

2- Past the following

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Windows Azure Tools for Microsoft Visual Studio 2010\1.0]

"VirtualMachineRoleEnabled"=dword:00000001

3- Save and rename the file” EnableVMRole-X64.reg”

4- Double click of the file, which will enable this role in the context menu in Visual studio.

clip_image005

Prepare VHD before upload to Azure

You can use Hyper-V Manager to create a new base VHD to be uploaded to Azure or you can use existing VHD. However the maximum size of VHD can be uploaded is 65 GB. After you create VHD follow the following steps:-

1-  Before start uploading you must install the Windows Azure Integration Components inside the virtual machine. The source of Windows Azure Integration Components is inside the installation path of windows Azure SDK %ProgramFiles%\Windows Azure SDK\<VersionNumber>\iso\ folder, select the wavmroleic.iso.

2-  Mount wavmroleic.iso to virtual machine which you want to upload its VHD to Azure and then double-click WaIntegrationComponents-x64.msi. Enter the Administrator password that is used when the operating system starts after the image is prepared and deployed to Windows Azure. Finish the installation of the components. You must restart the virtual machine for the components to be completely installed.

clip_image006

3- Open the Start menu, type %windir%\system32\sysprep\sysprep.exe and then press Enter to launch the System Preparation Tool. Set the System Cleanup Action to “Enter System Out-of-Box Experience (OOBE)”, check the option labeled Generalize, set the Shutdown Options to Shutdown, and then press OK.

clip_image007


Upload VHD to Windows Azure

Now you are ready to upload VHD to windows Azure

1- Open a Windows Azure SDK Command Promptas an administrator from Start | All Programs | Windows Azure SDK v1.x.

2- Run the following command

csupload Add-VMImage -Connection "SubscriptionId=[subscription_id]; CertificateThumbprint=[certificate_thumbprint]" -Description "[description]" -LiteralPath "[vhd_location]" –Name [vhd_filename] -Location "[azure_subregion]" -TempLocation %TEMP% -SkipVerify

For example:-

csupload Add-VMImage -Connection "SubscriptionId=XXXXXXXX-XXXX-XXXX-XXXX- XXXXXXXX; CertificateThumbprint=512DB65E1233C227DCD2067X5F7295BFEBA01X99" -LiteralPath d:\VMs2012\test.vhd -Location "West US"

3- Wait until VHD to be uploaded it depends on your VHD size and internet speed.

clip_image009

4- Once it finish go to the Management Portal, select the Hosted Services, Storage Accounts & CDN tab, and then VM Images. Notice that the list includes the test.vhd file that you are currently uploading and that its status is shown as Pending and once it finishes it will be committed.

Create new service model contains VM role

1- Configuring your Windows Azure Management Portal Credentials in Visual Studio.

 

clip_image011

2- Open Visual studio and create new cloud project

3- Don’t select any role and click OK.

clip_image012

4- Add new VM Role

clip_image014

5- Select your windows azure subscription you created in step 1 and select VHD for your virtual machine role.

clip_image015

6- In configuration tab select number of instance.

7- Finally, create a package to deploy your virtual machine role.

clip_image017

8- Click on “Configure Remote Desktop connection” to enable remote desktop on VMs which will be created.

clip_image018

9- Choose the newly created certificate from the drop down list, and then enter the name of the user that you will use to connect remotely to your VM. Finally enter a password and confirm it, and choose the account expiration date then click ok.

clip_image019

10- Click package, then wait until Visual Studio creates it. Once the package is ready, Visual Studio opens a window showing the folder that contains the generated files.

clip_image020

11- Go to Management Portal and create new hosted service using the files you got from step 10 and certificate we created earlier, then click ok.

clip_image022

Note that you must choose the same region you upload VHD to.

12- Wait until the status of the deployment is shown as ready.

image