13.Virtual Machine Role
Transcript of 13.Virtual Machine Role
-
7/31/2019 13.Virtual Machine Role
1/96
Page | 1
Hands-On Lab
Windows Azure Virtual Machine Roles
Lab version: 2.0.0
Last updated: 12/15/2010
-
7/31/2019 13.Virtual Machine Role
2/96
Page | 2
CONTENTS
OVERVIEW ................................................................................................................................................... 3
EXERCISE 1: CREATING AND DEPLOYING A VIRTUAL MACHINE ROLE IN WINDOWS AZURE ...... 4
Task 1 Building a Base Virtual Machine Image ................................................................................... 5Task 2 Preparing the Base Image for Deployment ........................................................................... 15
Task 3 Installing the Windows Azure VM Role Integration Components ........................................ 28
Task 4 Uploading the Disk Image to Windows Azure....................................................................... 36
Task 5 Creating the Service Model ................................................................................................... 40
Task 6 Creating the Hosted Service and Deploying the Package ..................................................... 47
EXERCISE 2: TROUBLESHOOTING WITH REMOTE DESKTOP ........................................................... 54 Task 1 Connecting to a Role Instance with Remote Desktop .......................................................... 54
Task 2 Using Powershell to Access the Windows Azure Runtime Environment .............................. 60
EXERCISE 3: UPDATING AND SERVICING A VIRTUAL MACHINE ROLE ........................................... 63 Task 1 Creating a Differencing Disk .................................................................................................. 63
Task 2 Updating a Virtual Machine Role OS Image .......................................................................... 73
SUMMARY .................................................................................................................................................. 77
APPENDIX A: CONFIGURING YOUR WINDOWS AZURE MANAGEMENT PORTAL CREDENTIALS INVISUAL STUDIO ........................................................................................................................................ 77
APPENDIX B: INSTALLING WINDOWS SERVER 2008 R2 .................................................................... 83
-
7/31/2019 13.Virtual Machine Role
3/96
Page | 3
Overview
Windows Azure Virtual Machine Roles allow you to run a customized instance of Windows Server 2008
R2 in Windows Azure, making it easier to move applications to the cloud.In this hands-on lab, you will explore Virtual Machine roles and you will learn how to create custom OSimages that you deploy to Windows Azure.
Objectives
In this hands-on lab, you will learn how to:
Prepare custom OS images that you can deploy to Windows Azure
Connect to your Windows Azure role instances with Remote Desktop for troubleshooting
Use differencing disks to apply updates to your Virtual Machine roles
Prerequisites
The following is required to complete this hands-on lab:
Windows Server 2008 R2 with Hyper-V role enabled
Hyper-V Manager
Microsoft .NET Framework 4.0
Microsoft Visual Studio 2010
Windows Azure Tools for Microsoft Visual Studio 1.3
Setup media for Windows Server 2008 R2 Enterprise Edition (Trial software available here )
Note: This hands-on lab requires a high-speed Internet connection to upload VM image files to yourWindows Azure subscription.
Important: Currently, access to VM Role is available through an invite-only beta program. Unless youhave enrolled in this program, you will not be able to complete this hands-on lab.
http://go.microsoft.com/fwlink/?linkid=186916http://go.microsoft.com/fwlink/?linkid=186916http://msdn.microsoft.com/vstudio/products/http://msdn.microsoft.com/vstudio/products/http://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://msdn.microsoft.com/vstudio/products/http://go.microsoft.com/fwlink/?linkid=186916 -
7/31/2019 13.Virtual Machine Role
4/96
Page | 4
Exercises
This hands-on lab includes the following exercises:
1. Creating and Deploying a Virtual Machine Role in Windows Azure
2. Troubleshooting with Remote Desktop
3. Updating and Servicing a Virtual Machine Role
Estimated time to complete this lab: 90 minutes .
Note: This hands-on lab involves certain procedures, for example, uploading VM image files toWindows Azure, that could potentially be time consuming. The estimate reflects the time required tocomplete each step that requires your active involvement and not the overall time required tocomplete every task.
Note: When you first start Visual Studio, you must select one of the predefined settings collections.Every predefined collection is designed to match a particular development style and determineswindow layouts, editor behavior, IntelliSense code snippets, and dialog box options. The procedures inthis lab describe the actions necessary to accomplish a given task in Visual Studio when using theGeneral Development Settings collection. If you choose a different settings collection for yourdevelopment environment, there may be differences in these procedures that you need to take intoaccount.
Exercise 1: Creating and Deploying aVirtual Machine Role in Windows Azure
In this exercise, you prepare the base image that you will deploy to Windows Azure.
In Hyper-V Server, you create a new virtual machine and perform a default installation of WindowsServer 2008 R2. After booting the virtual machine, you log in, install and configure the required OS
features, and then install the Windows Azure VM Role Integration Components. In a more realisticscenario, at this point, you would typically install additional software.
Once you have installed and configured all the required software, you apply the System Preparation Tool(sysprep.exe) to generalize the image, shut it down, and then you upload it to Windows Azure.
Next, you create a service model and configure it to use the deployed image, generate a servicepackage, and then deploy it to your subscription using the Windows Azure Platform Management Portal.
-
7/31/2019 13.Virtual Machine Role
5/96
Page | 5
Task 1 Building a Base Virtual Machine Image
In this task, you create a virtual machine in Hyper-V to build a base image of Windows Server 2008 R2.
1. Open Hyper-V Manager in the Start menu and connect to your Hyper-V Server.
Figure 1Hyper-V Manager console
2. In Hyper-V Manager, right-click the server name, point to New , and then select VirtualMachine . Click Next at the welcome screen to start the New Virtual Machine Wizard .
-
7/31/2019 13.Virtual Machine Role
6/96
Page | 6
Figure 2Creating a new virtual machine to prepare an image
3. In the Specify Name and Location step, set the name to VM Role and then click Next .
-
7/31/2019 13.Virtual Machine Role
7/96
Page | 7
Figure 3Choosing the name of the new virtual machine
4. In the Assign Memory step, set the amount of memory to 2048 MB and then click Next .
-
7/31/2019 13.Virtual Machine Role
8/96
Page | 8
Figure 4Configuring the amount memory assigned to the virtual machine
5. Next, in the Configure Networking step, select Local Area Connection - Virtual Network andthen click Next .
-
7/31/2019 13.Virtual Machine Role
9/96
Page | 9
Figure 5Configuring networking options for the virtual machine
Note: The network connection will be used by the virtual machine to access Windows Updateand apply required updates.
6. Now, in the Connect Virtual Disk step, select the option labeled Create a virtual hard disk . Setthe Name of the disk to baseimage.vhd , change the location to a suitable folder in your Hyper-Vserver, set the disk Size to 30GB, and then click Next to continue.
-
7/31/2019 13.Virtual Machine Role
10/96
Page | 10
Figure 6Creating a new virtual hard disk
Note: The VHD size must fit the quota allocated for the chosen VM size for you role. In thiscase, setting the size to 30GB allows you to deploy the VM in a small role.
If you already have a VHD file with a clean installation of Windows Server 2008 R2, you may usethat instead. To do this, select the option labeled Use an existing virtual hard disk and browseto the location of the VHD file. Note that the image file must contain a single partition with theOS installation and must not include a recovery partition.
Note: If you use an existing image, after you create the virtual machine, you may skip the OSinstallation section of this task and proceed to the next task.
-
7/31/2019 13.Virtual Machine Role
11/96
Page | 11
Figure 7Using an existing virtual hard disk
7. In the Installation Options step, choose the option that is the most suitable for the type of setup media that you have, and then click Next .
-
7/31/2019 13.Virtual Machine Role
12/96
Page | 12
Figure 8Installing an operating system from the setup media
Note: To create a base image for the Virtual Machine Role, you require setup media forWindows Server 2008 R2 Enterprise Edition. Click here to download trial software.
http://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspxhttp://www.microsoft.com/windowsserver2008/en/us/trial-software.aspx -
7/31/2019 13.Virtual Machine Role
13/96
Page | 13
Figure 9Completing the Virtual Machine Wizard
8. Click Finish to create the virtual machine.
9. In Hyper-V Manager, in the results pane, under Virtual Machines , right-click the name of thenewly created virtual machine and then select Connect .
Note: If Hyper-V manager does not list the virtual machine, you may need to right-click theserver name and select Refresh .
10. In the toolbar of the Virtual Machine Connection window, click the Start icon.
-
7/31/2019 13.Virtual Machine Role
14/96
Page | 14
Figure 10Starting the virtual machine in Hyper-V
Note: Virtual Machine Connection is a tool that you use to connect to a virtual machine so thatyou can install or interact with the guest operating system.
11. Start the virtual machine to launch the Windows Server 2008 R2 installation procedure.
Note: If the installation does not start automatically, you may have specified an incorrectlocation of the setup media for Windows Server 2008 R2 in the Installation Options page of the New Virtual Machine wizard.
12. Install Windows Server 2008 R2 Enterprise edition using default settings. The only specialrequirement for a valid VM Role image is to allocate the entire virtual hard disk file to a singlepartition where you install the operating system. To avoid creating a recovery partition duringthe installation, follow these steps:
-
7/31/2019 13.Virtual Machine Role
15/96
-
7/31/2019 13.Virtual Machine Role
16/96
Page | 16
Figure 11 Adding a new server role
4. In the Server Roles step, select the Web Server (IIS) role in the list and click Next .
-
7/31/2019 13.Virtual Machine Role
17/96
Page | 17
Figure 12Installing the Web Server role
5. In the Web Server (IIS) step, click Next .
-
7/31/2019 13.Virtual Machine Role
18/96
Page | 18
Figure 13Web Server (IIS) step
6. In the Role Services step, click Next without selecting any additional components.
-
7/31/2019 13.Virtual Machine Role
19/96
Page | 19
Figure 14Configuring Web Server role components
7. In the Confimation step, ensure that the Web Server role is included in the list of services andthen click Install .
-
7/31/2019 13.Virtual Machine Role
20/96
Page | 20
Figure 15Confirming the installation selections
8. Wait for the installation to complete and then click Close .
-
7/31/2019 13.Virtual Machine Role
21/96
Page | 21
Figure 16Successful installation of the Web Server role
9. Next, in Server Manager, select the Features node and then click Add Features .
-
7/31/2019 13.Virtual Machine Role
22/96
Page | 22
Figure 17Installing additional features
10. In the Features step, expand .NET Framework 3.5.1 Features , select .NET Framework 3.5.1 andthen click Next .
-
7/31/2019 13.Virtual Machine Role
23/96
Page | 23
Figure 18Installing the .NET Framework prerequisite
Note: The VM Role Integration Components require .NET Framework 3.5.1. You will installthese components in the next task.
11. In the Confirmation step, click Install .
-
7/31/2019 13.Virtual Machine Role
24/96
Page | 24
Figure 19Confirming the installation of the .NET Framework features
12. In the Results step, click Close .
-
7/31/2019 13.Virtual Machine Role
25/96
Page | 25
Figure 20Successful installation of the .NET Framework feature
13. Open the Windows Update control panel from Start | All Programs | Windows Update .
14. In the Windows Update page, select Change Settings .
-
7/31/2019 13.Virtual Machine Role
26/96
Page | 26
Figure 21Changing Windows Update settings
15. In the Change Settings page, select the option labeled Never check for updates (notrecommended) and then click OK.
-
7/31/2019 13.Virtual Machine Role
27/96
Page | 27
Figure 22Disabling Windows Updates in the VM Role image
16. Next, click Check for updates and install all available updates.
-
7/31/2019 13.Virtual Machine Role
28/96
Page | 28
Figure 23Installing Windows Updates before deploying the VM Image
Note: If prompted, you may need to reboot and repeat the check for updates in case there areadditional updates to install.
Task 3 Installing the Windows Azure VM Role Integration Components
In this task, you install the Windows Azure VM Role Integration Components.
1. In the Virtual Machine Connection window, in the Media menu, point to DVD Drive and thenselect Insert Disk . In the Open dialog, browse to the location of the ISO file for the VM RoleIntegration Components, wavmroleic.iso , and then click Open .
-
7/31/2019 13.Virtual Machine Role
29/96
Page | 29
Figure 24Connecting the VM Role Integration Components installation ISO file to the virtual CD/DVD drive
Note: If you have not installed the Windows Azure SDK in your Hyper-V server, you will needto copy the wavmroleic.iso file from another computer were you installed the SDK to theHyper-V servers hard disk. You will find this file in the iso folder of the Windows Azure SDKinstallation directory.
2. After you connect the ISO file to the DVD drive of the virtual machine, wait for the AutoPlay dialog to appear and then click Open folder to view files using Windows Explorer .
Figure 25Browsing the VM Role Integration Components ISO file
Note: If the AutoPlay feature is not enabled, open a Windows Explorer window and browse tothe CD/DVD drive.
-
7/31/2019 13.Virtual Machine Role
30/96
Page | 30
3. In the Windows Explorer window, locate the WaIntegrationComponents-x64.msi (WindowsInstaller) file and double-click it to start the installation.
Figure 26Launching the installation of the VM Role Integration Components
4. At the Welcome screen, click Next to proceed.
-
7/31/2019 13.Virtual Machine Role
31/96
Page | 31
Figure 27Windows Azure VM Role Integration Components Setup Welcome screen
5. In the Operating System Configuration step, enter an Administrator Password , confirm it, andthen click Next .
-
7/31/2019 13.Virtual Machine Role
32/96
Page | 32
Figure 28Configuring the administrator password
6. Click Install to begin the installation of the Integration Components.
-
7/31/2019 13.Virtual Machine Role
33/96
Page | 33
Figure 29Beginning the installation of the VM Role Integration Components
7. When prompted to install device software, click Install to proceed.
Figure 30Installing required device drivers
8. Wait for the installation to complete, which should only take a few seconds.
-
7/31/2019 13.Virtual Machine Role
34/96
Page | 34
Figure 31Monitoring the progress of the installation
9. Click Finish to exit the setup program.
-
7/31/2019 13.Virtual Machine Role
35/96
Page | 35
Figure 32Successful installation of the VM Role Integration Components
10. Once the installation of the components has finished, you will be prompted to restart thesystem. Click Yes to continue.
Figure 33
Restarting the system to complete the installation of the integration components
11. Wait for the system to restart and log in to the guest machine once again.
12. Now, inside the VM, open the Start menu, type %windir%\system32\sysprep\sysprep.exe andthen press Enter to launch the System Preparation Tool . Set the System Cleanup Action to
-
7/31/2019 13.Virtual Machine Role
36/96
-
7/31/2019 13.Virtual Machine Role
37/96
Page | 37
Hyper-V
Windows Azure data center location where the hosted servicewill be deployed (choose from Anywhere Asia, AnywhereEurope, Anywhere US, East Asia, North Central US,North Europe, South Central US, Southeast Asia, West
Europe)
Windows Azure Command Prompt
csupload Add-VMImage -Connection "SubscriptionId=;CertificateThumbprint=" -Description "Base imageWindows Server 2008 R2" -LiteralPath "" -Name baseimage.vhd-Location
Note: The Connection parameter contains settings required to access and manage your
subscription. If you regularly use the csupload tool, you may store this connection string inyour local disk using the Set-Connection command and then execute commands withoutspecifying the connection details each time.
4. Press Enter to start execution.
5. In the Windows Azure VHD Verification Tool dialog, click OK to allow the VHD to be mounted. If the AutoPlay dialog appears, close it.
Figure 35
Mounting the VHD for verification
Note: Initially, the tool executes a preparation phase where it mounts the VHD file and verifiesit. It then processes the file to create a smaller compressed copy. The file it generates has a.preped extension and it stores it by default in the same folder as the original image file. To
-
7/31/2019 13.Virtual Machine Role
38/96
Page | 38
change the folder where csupload stores this file, use the TempLocation parameter and thenspecify the path to the alternate location.
Figure 36Preparation phase of the csupload tool
6. After the preparation phase completes, the tool creates a new blob to hold the image file andthen begins to upload the compressed image to your Windows Azure account.
Figure 37Uploading phase of the csupload tool
-
7/31/2019 13.Virtual Machine Role
39/96
Page | 39
Note: Base image files are typically large and, depending on the speed of your Internetconnection, may take a significant amount of time to upload.
7. In the Management Portal, select the Hosted Services, Storage Accounts & CDN tab, and thenVM Images . Notice that the list includes the baseimage.vhd file that you are currently uploadingand that its status is shown as Pending .
Figure 38 Available VM Images including the image currently being uploaded
8. Wait for the upload to complete, which may take several hours, if your connection is not veryfast.
-
7/31/2019 13.Virtual Machine Role
40/96
Page | 40
Figure 39VM image successfully uploaded to Windows Azure
9. Examine the status of the VM role image in the Management Portal and verify that it has nowchanged to Committed .
Figure 40Image committed successfully after finishing the upload
Task 5 Creating the Service Model
-
7/31/2019 13.Virtual Machine Role
41/96
Page | 41
After completing the previous task, you now have a VM image deployed to your Windows Azureaccount. In this task, you create a service model and configure it to reference this image.
1. Start Microsoft Visual Studio 2010 .
2. In Visual Studio, create a new Windows Azure Project . You may choose any language, Visual C#
or Visual Basic, because you will only use Visual Studio to create the service model and generatethe service package. Set the name of the project to MyVMRole , change the location to theSource folder of the lab, ensure that the option labeled Create directory for solution is checked,and set the solution name to Begin . Click OK to create the project.
Figure 41Creating a new Windows Azure Project
3. In the New Windows Azure Project dialog, click OK without adding any roles. You will create aVirtual Machine role in the following steps.
-
7/31/2019 13.Virtual Machine Role
42/96
Page | 42
Figure 42Creating a project to host the Virtual Machine Role
4. Once the solution is created, right-click the Roles folder inside the MyVMRole project, point toAdd , and then select New Virtual Machine Role .
Figure 43 Adding a new Virtual Machine Role to the project
Note: Currently, access to VM Role is available through an invite-only beta program. If youenroll in this program, you will receive instructions for enabling the required functionality inthe Windows Azure Tools for Visual Studio; otherwise, you may not see the required menuoption.
-
7/31/2019 13.Virtual Machine Role
43/96
Page | 43
5. In the properties window for the new role, select the Virtual Hard Disk tab. To show thewindow, expand the Roles node in Solution Explorer and then double-click the VMRole1 role.
6. Before you can choose an image to use for your VM role, you need to configure Visual Studio to
access your Windows Azure account. If you have used Visual Studio previously to deploy servicepackages to Windows Azure, you may already have created the required credentials. Forinstructions on how to do this, see Appendix A - Configuring your Windows Azure ManagementPortal Credentials in Visual Studio .
7. Once you configure the credentials, choose them in the drop down list labeled Select or createyour Windows Azure account credentials . After you do this, Visual Studio accesses yoursubscription and retrieves a list of available virtual machine images.
8. Expand the drop down list labeled Select VHD and choose the image named baseimage.vhd ,which contains the installation of Window Server 2008 R2 Enterprise Edition that you uploaded
earlier.
Figure 44Choosing a VHD for your virtual machine role
Note: The drop down lists every VHD that you upload to your subscription.
9. Configure an endpoint to allow external connections to the Web server in the VM Role. To dothis, in the role properties window, switch to the Endpoints tab. Click Add Endpoint to create a
-
7/31/2019 13.Virtual Machine Role
44/96
Page | 44
new entry in the endpoints list. Set the name of the endpoint to HttpIn , select Input in the Type column, http as the Protocol and type 80 for both Public Port and Private Port values.
Figure 45Configuring an external endpoint for the virtual machine role
Note: In this hands-on lab, you enable the Web Server feature in the VM image to provide asimple mechanism to determine when the role starts successfully; hence the need to declarethe input endpoint.
10. Next, configure the Remote Desktop connections for your role. To do this, right-click theMyVMRole cloud service project in Solution Explorer and select Publish . In the DeployWindows Azure project dialog box, click Configure Remote Desktop connections.
-
7/31/2019 13.Virtual Machine Role
45/96
Page | 45
Figure 46Preparing for deployment
11. In the Remote Desktop Configuration dialog, check the option labeled Enable connections forall roles .
12. Expand the drop down list labeled Create or select a certificate to encrypt the user credentials and select Create .
13. In the Create Certificate dialog, enter a name to identify the certificate, for example, AzureRemote , and then click OK.
Figure 47Creating a certificate for Remote Desktop connections
-
7/31/2019 13.Virtual Machine Role
46/96
-
7/31/2019 13.Virtual Machine Role
47/96
Page | 47
Figure 49Creating a service package in Visual Studio
Task 6 Creating the Hosted Service and Deploying the Package
In this task, you create a new hosted service for your Virtual Machine role and then deploy the servicepackage.
1. Return to the browser window showing the Management Portal.
2. Create a hosted service for your virtual machine role. To do this, select the Hosted Services,Storage Accounts & CDN tab followed by Hosted Services , and then click New Hosted Service on the ribbon.
-
7/31/2019 13.Virtual Machine Role
48/96
Page | 48
Figure 50Creating a hosted service for your virtual machine
3. In the Create a new Hosted Service dialog, enter a Service Name , for example, MyVMRole, andthe URL that you wish to assign to the service. Remember that this URL is public, therefore, itneeds to be unique and can only contain characters that are valid in a URL. The dialog validatesthe name as you type it and warns you if the name you choose has already been taken. Pick theregion where you want to host the service from the drop down list labeled Choose a region andensure that it is the same region where you uploaded the VM image in the previous task.
Finally, in the Deploy pane, select the option labeled Do not deploy , and then click OK.
-
7/31/2019 13.Virtual Machine Role
49/96
-
7/31/2019 13.Virtual Machine Role
50/96
Page | 50
4. Upload the certificate used to encrypt the Remote Desktop password to the newly createdservice. To do this, expand the node for your hosted service to display and select theCertificates node and then click Add Certificate on the ribbon.
Figure 52Configuring service certificates
5. In the Upload an X.509 Certificate dialog, click Browse and navigate to the location where youstored the certificate for Remote Desktop that you created and exported during the previoustask, enter the assigned password, confirm it, and then click Create .
Figure 53
-
7/31/2019 13.Virtual Machine Role
51/96
Page | 51
Uploading the Remote Desktop certificate to the service
6. Once you create the service, select it in the items pane of the Management Portal page, andthen click New Production Deployment on the ribbon.
Figure 54Creating a new deployment for the service
7. In the Create a new Deployment dialog, click Browse Locally next to the Package Location textbox and then navigate to the location where Visual Studio generated the service package duringthe previous task. You should have a Windows Explorer window already open showing thecorrect location. Choose the service package file with a .cspkg extension and click Open . Repeatthe same procedure to choose the Configuration File with a .cscfg extension in the samelocation. Finally, enter a label to identify your deployment, and click OK.
-
7/31/2019 13.Virtual Machine Role
52/96
-
7/31/2019 13.Virtual Machine Role
53/96
Page | 53
Figure 57Hosted service successful start
10. To verify that the role started successfully, open the home page of your VM role in yourbrowser. You can find its URL in the Properties window of your deployment, which correspondsto the web server (port 80) endpoint that you defined while creating the service model.
Figure 58 Accessing the input endpoint of the VM role
11. Verify that you can access the default page in IIS, as shown in the image below.
-
7/31/2019 13.Virtual Machine Role
54/96
Page | 54
Figure 59 Accessing the web server running in the VM role
Exercise 2: Troubleshooting with RemoteDesktop
Remote Desktop allows you to connect to a role instance for troubleshooting purposes. In this exercise,you connect to an instance of your VM role and use Powershell to access the service runtimeenvironment.
Task 1 Connecting to a Role Instance with Remote Desktop
-
7/31/2019 13.Virtual Machine Role
55/96
Page | 55
In this task, you connect to your running role instances using Remote Desktop.
1. Once the roles status changes to Ready , expand the deployment in the center pane to show itsinstances and select the line labeled VM Instance there should only be a single instance for thecurrent deployment and then click Connect on the ribbon.
Figure 60Connecting to a role instance with Remote Desktop
2. Download the Remote Desktop connection file from the Management Portal. Depending onyour browser security configuration, the browser may block the download and prompt you forconfirmation. If this happens, you may need to allow the download to proceed and then repeatthe previous step once the page refreshes. In the File Download dialog, click Open .
-
7/31/2019 13.Virtual Machine Role
56/96
Page | 56
Figure 61Downloading the Remote Desktop connection file
3. If prompted by a security warning from your browser, click Allow to proceed.
Figure 62 Allowing the remote desktop connection to proceed
4. Click Connect in the Remote Desktop Connection dialog.
-
7/31/2019 13.Virtual Machine Role
57/96
Page | 57
Figure 63Downloading the Remote Desktop connection file
5. In the Windows Security dialog, enter the credentials that you specified earlier when youconfigured the Remote Desktop connection for the role, and then click OK.
Figure 64Entering your Remote Desktop credentials
-
7/31/2019 13.Virtual Machine Role
58/96
Page | 58
6. Wait until the connection is established.
Figure 65Waiting for the connection to be established
7. Remote Desktop prompts you with a dialog warning that the identity of the remote computercannot be verified. Click Yes to proceed.
Figure 66Verifying the identity of the remote computer
8. Once authenticated, the connection is quickly established and a window showing the desktopfor the chosen role instance should open.
-
7/31/2019 13.Virtual Machine Role
59/96
Page | 59
Figure 67Remote Desktop connected to the virtual machine role instance
Note: If you have trouble connecting with your credentials, you can configure the remotedesktop credentials from the Management Portal. To do this, select the role that you want toconfigure, and then click User Access in the Remote Access section of the ribbon.
Figure 68Configuring Remote Desktop for a role
-
7/31/2019 13.Virtual Machine Role
60/96
Page | 60
Figure 69Configuring the Remote Desktop credentials using the Management Portal
9. At this point, you may use the remote desktop connection to explore your virtual machinerunning in the cloud.
Task 2 Using Powershell to Access the Windows Azure Runtime Environment
In this task, you use a Powershell snap-in to stop network traffic to the current role instance.
1. In the Remote Desktop session, open a Powershell console window as an administrator .
2. At the command prompt, type the following command to add a Powershell snap-in to thecurrent session. This snap-in is installed with the integration components and provides access tothe Windows Azure runtime environment.
Powershell
Add-PSSnapin Microsoft.WindowsAzure.ServiceRuntime
3. To view all the commands available in the snap-in, enter the following command:
C#
Get-Command -module Microsoft.WindowsAzure.ServiceRuntime
-
7/31/2019 13.Virtual Machine Role
61/96
Page | 61
Figure 70Viewing available commands in the service runtime Powershell snap-in
Note: You may view additional information for any of these commands by executing:
Get-Help
where is the name of the command.
4. To remove the current role instance from the load balancer rotation and prevent traffic frombeing forwarded to this instance, type the following command:
Powershell
Set-RoleInstanceStatus -Busy
-
7/31/2019 13.Virtual Machine Role
62/96
Page | 62
Figure 71Stopping network traffic to the current role instance
5. Examine the status of the deployment in the Management Portal and notice that it now showsthe status of the hosted service as Busy .
Figure 72
Role instance status showing that it has been removed from the load balancer rotation
6. Close the Powershell window and then examine the status of the role instance at theManagement Portal. Notice that after a brief delay, the status returns to Ready and the role isready once again to receive external traffic.
Note: The status of the role instance can also be restored by executing the followingcommand:
Set-RoleInstanceStatus -Ready
-
7/31/2019 13.Virtual Machine Role
63/96
-
7/31/2019 13.Virtual Machine Role
64/96
Page | 64
Figure 73Creating a differencing disk
5. Now, in the Specify Name and Location step, set the Name of the disk to diffimage.vhd , changethe location to a suitable folder in your Hyper-V server, and then click Next .
-
7/31/2019 13.Virtual Machine Role
65/96
Page | 65
Figure 74Choosing the name and location of the disk
6. In the Configure Disk step, browse to the base image that you previously deployed and chooseit as the parent of the new differencing virtual hard disk. Click Next to proceed.
-
7/31/2019 13.Virtual Machine Role
66/96
Page | 66
Figure 75Configuring the parent image for the differencing disk
7. Click Finish to create the VHD file in your computer.
-
7/31/2019 13.Virtual Machine Role
67/96
Page | 67
Figure 76Confirming the creation of the differencing virtual hard disk
Once you create the differencing disk, you now configure the virtual machine to use it.
8. In the Hyper-V console, ensure the virtual machine that you set up at the start of the lab isturned off and then right-click its node to select Settings .
9. In the Hardware section on the left pane, select the Hard Drive node under IDE Controller 0 .Next, click Browse to select the differencing disk that you just created and then OK to apply thechanges.
-
7/31/2019 13.Virtual Machine Role
68/96
Page | 68
Figure 77Replacing the VHD disk file in the virtual machine with the differencing disk
10. Start the guest operating system. To do this, right-click the virtual machine in the Hyper-VManager and select Connect to open a Virtual Machine Connection . Then, click the Start button i n the windows toolbar.
11. Wait for the virtual machine to boot and then log in using the credentials that you assignedpreviously, when you initialized the base image and installed the tools.
-
7/31/2019 13.Virtual Machine Role
69/96
-
7/31/2019 13.Virtual Machine Role
70/96
Page | 70
Figure 79
Using the text tool to modify the default welcome page in IIS
Figure 80Overlaying a caption on the image
15. Save the file.
16. Once again, you need to prepare the differencing disk for deployment. To do this, inside theVM, 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 E nter System Out-of-Box Experience (OOBE) , check Generalize, set the Shutdown Options to Shutdown , and thenpress OK.
-
7/31/2019 13.Virtual Machine Role
71/96
Page | 71
17. Wait for the system to completely shutdown. Your differencing image is now ready fordeployment to Windows Azure. To deploy this image, you will follow a similar procedure to theone that you used earlier, when you uploaded the base image.
18. Open a Windows Azure SDK Command Prompt as an administrator from Start | All Programs |Windows Azure SDK v1.x .
19. At the command prompt, execute the following command line, where:
ID of your Windows Azure subscription that you obtain fromthe Management Portal
Thumbprint of the management certificate that you cangenerate in Visual Studio and upload to the ManagementPortal (see Appendix A: Configuring your Windows AzureManagement Portal Credentials in Visual Studio )
Path to the differencing disk image file, diffimage.vhd, that you
built in Hyper-V Windows Azure data center location where the hosted service
will be deployed (choose from Anywhere Asia, AnywhereEurope, Anywhere US, East Asia, North Central US,North Europe, South Central US, Southeast Asia, WestEurope)
Choose the same region used for the base image
Windows Azure Command Prompt
csupload Add-VMImage -Connection "SubscriptionId=;
CertificateThumbprint=" -Description"Differencing image with updated logo" -LiteralPath "" -Namediffimage.vhd -Location
20. Press Enter to start execution.
-
7/31/2019 13.Virtual Machine Role
72/96
Page | 72
Figure 81Uploading the differencing disk image
21. In the Windows Azure VHD Verification Tool dialog, click OK to allow the VHD to be mounted. If the AutoPlay dialog appears, close it.
22. Wait until the uploading process completes. Because the differencing disk is considerablysmaller, this should be significantly faster than uploading the base image.
23. Now, at the command prompt, enter the following command to associate the differencing diskwith its base image.
ID of your Windows Azure subscription that you obtain fromthe Management Portal
Thumbprint of the management certificate that you cangenerate in Visual Studio and upload to the ManagementPortal (see Appendix A: Configuring your Windows AzureManagement Portal Credentials in Visual Studio )
Windows Azure Command Prompt
csupload Set-Parent -Connection "SubscriptionId=;CertificateThumbprint=" -Child diffimage.vhd -Parent baseimage.vhd
24. Now, go back to the Management Portal, select the Hosted Services, Storage Accounts, & CDN tab, and then VM Images . Notice how the portal now shows the differencing disk as a child of the base image.
-
7/31/2019 13.Virtual Machine Role
73/96
Page | 73
Figure 82Base image and its differencing disk
Task 2 Updating a Virtual Machine Role OS Image
In this task, you update the service model to use the differencing disk and deploy it to Windows Azure toallow the Virtual Machine role to boot from the replacement disk image. Changing the image that a roleboots from is easily achieved by updating the OsImage element in the configuration file. You can do thisat the Management Portal, without stopping the service.
1. Browse the Windows Azure Platform Management Portal at https://windows.azure.com/ and, if necessary, sign in with your Live ID.
2. At the Management Portal, select the Hosted Services, Storage Accounts & CDN tab and thenHosted Services .
3. Locate the hosted service that you created earlier and select the deployment that contains the
base image VHD. Then, click Configure in the Deployments group of the ribbon.
https://windows.azure.com/https://windows.azure.com/https://windows.azure.com/https://windows.azure.com/ -
7/31/2019 13.Virtual Machine Role
74/96
Page | 74
Figure 83Updating the configuration of your service deployment
4. In the Configure Deployment dialog, select the option labeled Edit current configuration .Notice that the contents of the Settings text box contain the settings that you defined when you
created the service model and built the package in Visual Studio.5. In the Settings text box, locate the OsImage element and change the value of its href attribute
from baseimage.vhd to diffimage.vhd .
-
7/31/2019 13.Virtual Machine Role
75/96
Page | 75
Figure 84Updating the image used by the virtual machine role
6. Click OK to save the changes and update the role configuration. Notice that the ManagementPortal changes the status of the deployment to Updating while the changes are applied.
Figure 85Waiting for the changes to the OS image to take effect
-
7/31/2019 13.Virtual Machine Role
76/96
-
7/31/2019 13.Virtual Machine Role
77/96
Page | 77
Summary
In this hands-on lab, you explored the basic features of Windows Azure Virtual Machine roles and saw
how to create custom OS images and prepare them for deployment to the cloud.
Appendix A: Configuring your WindowsAzure Management Portal Credentials inVisual Studio
Follow these steps to create the credentials that you can use to access your Windows Azure subscriptionfrom Visual Studio.
1. To add a new set of credentials, open an existing Windows Azure project or create a new one.
2. Open a Windows Azure Project Management Authentication dialog. To do this, use one of thefollowing two procedures:
a. In Solution Explorer , right-click the Windows Azure project and select Publish .
b. In the Deploy Windows Azure project dialog, make sure that the option labeled Deployyour Windows Azure project to Windows Azure is selected, expand the drop down listlabeled Credentials , and then select Add .
Figure 87Configuring Windows Azure account credentials - Option A
Alternatively,
-
7/31/2019 13.Virtual Machine Role
78/96
-
7/31/2019 13.Virtual Machine Role
79/96
Page | 79
Figure 89Choosing a certificate for authentication
6. Now, click the link labeled Copy the full path to store the path to the certificate file in theclipboard.
Figure 90
-
7/31/2019 13.Virtual Machine Role
80/96
Page | 80
Copying the path of the generated certificate public key file to the clipboard
Note: Visual Studio stores the public key file for the certificate it generates in a temporaryfolder inside your local data directory.
7. Click OK to dismiss the confirmation message box and then save the path in the clipboard to asafe location. You will need this value shortly, when you upload the certificate to the portal.
Figure 91Confirmation that the file path was copied to the clipboard successfully
8. Now, in the Windows Azure Project Management Authentication dialog, click the link labeledWindows Azure Portal to open a browser window and navigate to the Management Portal.
-
7/31/2019 13.Virtual Machine Role
81/96
Page | 81
9. At the Management Portal, if you have not already done so, sign in using your Windows Live ID.
10. Select the Hosted Services, Storage Accounts & CDN option, click Management Certificates ,and then click Add Certificate on the ribbon.
Figure 92 Adding a new management certificate to your subscription
11. In the Add New Management Certificate dialog, click Browse , change the file name to the pathfor the public key (.cer) file generated by Visual Studio that you copied earlier to your clipboard,and then click Open . Click Done to upload the certificate to the Management Portal.
Figure 93Uploading a management certificate
-
7/31/2019 13.Virtual Machine Role
82/96
Page | 82
12. In the Properties pane, make a record of your subscription ID. You will need it in the next step.
Figure 94Retrieving your subscription ID from the Management Portal
13. Go back to the Windows Azure Project Management Authentication dialog in Visual Studio andpaste the value retrieved from the Management Portal into the subscription ID textbox.
-
7/31/2019 13.Virtual Machine Role
83/96
-
7/31/2019 13.Virtual Machine Role
84/96
Page | 84
Figure 96Installation loading files from the setup media
2. Choose the language to install, the time and currency format, and the default keyboard layoutand then choose Next .
-
7/31/2019 13.Virtual Machine Role
85/96
Page | 85
Figure 97Configuring the language and regional settings
3. Click Install now to begin the installation.
-
7/31/2019 13.Virtual Machine Role
86/96
Page | 86
Figure 98Starting the installation process
4. Choose the Windows Server 2008 R2 Enterprise server edition and then click Next .
-
7/31/2019 13.Virtual Machine Role
87/96
Page | 87
Figure 99Choosing the server edition to install
5. Read and accept the license terms. Then, click Next to proceed.
-
7/31/2019 13.Virtual Machine Role
88/96
Page | 88
Figure 100 Accepting the licensing agreement
6. Choose the Custom (advanced) installation type.
-
7/31/2019 13.Virtual Machine Role
89/96
Page | 89
Figure 101Choosing an installation type
7. When prompted to choose an installation location, press Shift+F10 to open a command prompt.
-
7/31/2019 13.Virtual Machine Role
90/96
Page | 90
Figure 102You can open a command prompt by pressing Shift + F10 now
8. At the command prompt, type diskpart and press Enter .
Figure 103
-
7/31/2019 13.Virtual Machine Role
91/96
Page | 91
Launching the diskpart tool
9. Now, type list disk and press Enter to enumerate available disks there should be a single diskonly.
Figure 104Enumerating available disks
10. Next, type select disk 0 and press Enter .
Figure 105Selecting the current disk
-
7/31/2019 13.Virtual Machine Role
92/96
Page | 92
11. Type create partition primary and then press Enter to create a partition that spans the entiredisk.
Figure 106Creating a primary partition
12. Finally, type exit and then press Enter .
Figure 107Exiting the diskpart tool
13. Close the command prompt window.
-
7/31/2019 13.Virtual Machine Role
93/96
Page | 93
14. Back in the GUI, click Refresh to update the list of available partitions, choose the newly createdpartition and then click Next .
Figure 108
Choosing a partition to install the operating system
15. Wait for the installation to complete.
-
7/31/2019 13.Virtual Machine Role
94/96
Page | 94
Figure 109Windows installation showing the current progress
16. Once the installation completes and the system boots successfully, in the virtual machine, clickOK to set up the administrators password and log in for the first time.
-
7/31/2019 13.Virtual Machine Role
95/96
-
7/31/2019 13.Virtual Machine Role
96/96
Figure 111Logging in for the first time