Lessons Learned in Testing the TreyResearch Sample Windows Azure Application

Setting Test Environment in the Cloud - Part 2: Deploy Visual Studio VM

Introduction

We created and deployed Visual Studio VM Role Instances in the cloud during the course of testing the TreyResearch Windows Azure Hybrid Application. We use the VM to perform local load test, distributed load test, as well as function test.

Lessons learned

We learned the following lessons in creating, deploying, and using Visual Studio VM Role instances in the :

  • Starting from a base VHD file can save time. Remember to increase the disk size. We increased our Visual Studio VM disk size to 50GB. Our base VHD only have 15 GB disk size.

  • Use sa authentication or mixed mode authentication when installing SQL Server or SQL Server Express in the VHD even if we would eventually use the integrated Windows Authentication when the VM Role instance is in the cloud. The reason is that after Sys-prep the computer identity will be changed and the Windows user (even for the administrator) in the original VHD will become invalid, and we would be unable to access the SQL Server.

  • Make sure that certain port is open. this include icmpv6, tcp port 445, inbound 6901 port and 6910 port.

  • Always test the VHD after sys-prep. After the VHD is sys-preped, we always save it and test it to make sure that the software installed still works. This step will catch issues such as not being able to access the SQL Server due to authentication settings not using sa.

  • Upload the vhd to the cloud at the end of day and check it next morning can save us time. The vhd upload can take hours. Again, test the vhd before uploading.

  • Share the vhd with the team members. All team can use the same vhd image, but different VM role instances if every one has a valid VS license. That can save a lot of installation time.

Steps for Creating and Deploying Visual Studio VM Role

Steps to Create VSClient.vhd

1. Copy AzureBase.vhd to VSClient.vhd

If you don’t already have AzureBase.vhd, prepare AzureBase.vhd following the steps in Setting Test Environment in the Cloud - Part 1: Creating Base VHD Hyper-V Image. Copy AzureBase.vhd to VSClient.vhd. (We use the name VSClient since we will use it as the VS Client machine in distributed load test).

2. Extend vhd disk size to 50GB

  • Start Hyper-V manager; create a new VM and name it VSClient, pointing the vhd to the newly copied VSClient.vhd.

  • Once the VM is configured, start the VM.

  • Inside the VM, start the Server Manger, go to Storage->Disk Management, and Extend Volume of the C drive to 50GB.

  • Go to the property of C:\, and verify that its capacity is 50GB

3. Install VS2010 Ultimate and SP1

  • Run visual studio 2010 ultimate setup.exe

  • Run Visual Studio 2010 SP1 Setup.exe

  • Install Visual Studio Load Test Virtual User Pack 2010: Visual Studio 2010 Ultimate allows you to stress test your application with 250 virtual users on a local load test run. If your load testing requires more virtual users, or if you want to use remote machines, you must purchase Visual Studio Load Test Virtual User Pack 2010.

  • Install Visual Studio 2010 Load Test Feature Pack if you are MSDN subscribers. MSDN subscribers with Visual Studio Ultimate are provided a license key to generate UNLIMITED virtual users without having to purchase the Visual Studio Load Test Virtual User Pack 2010.

  • Configure SQLExpress Authentication Mode to Mixed Mode

4. Install SQL Server 2008 R2

Note: If you don’t install SQL server, SQLExpress will be used for storing load test result by default, which limits storage space to 4GB.

  • Run SQL Server installation set program setup.exe

  • Select Mixed Mode (SQL Server authentication and Windows authentication) for Authentication Mode.

  • Use NT Authority\Network Service for the account of all the services.

  • Enter NT Authority\System account where windows account is required. Don’t use ComputerName\administrators since the Computer Name will change after SysPrep.

5. Run Windows update

  • Run Windows update. You may need to run it multiple times to get all the updates.

6. Run Sysprep to Prepare Image for Cloning

  • The purpose of this step is to prepare the image for cloning by generalizing unique elements that are present on the operating system like computer names, security identifiers and driver cache. By doing this step we will be able to clone from this image and generate VMs that are unique after the base image is uploaded.
  • Now, inside the VM, 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.
  • Note: The Sysprep tool (Sysprep.exe) prepares the image by cleaning up various user and machine settings and log files, as well as removing any hardware-dependent information.
  • Wait for the system to completely shut down. Our image is now ready for deployment.

Steps to Upload VSClient.vhd to the Cloud

1. Run CsUpload tool to upload VSClient.vhd to Windows azure in the cloud

In this step, we upload the VHD file to the Management Portal.

  • Open a Windows Azure SDK Command Prompt as an administrator from Start | All Programs | Windows Azure SDK v1.x. At the command prompt, execute the following command line:
    CsUpload Add-VMImage
    -Connection "SubscriptionId=< SUBSCRIPTION-ID >; CertificateThumbprint=< CERTIFICATE-THUMBPRINT >"
    -Description "Our Description"
    -LiteralPath "<PATH-TO-VHD-FILE>"
    -Name “VSClient.vhd”
    -Location “<HOSTED-SERVICE-LOCATION>”
    Example:
    CsUpload Add-VMImage
    -Connection "SubscriptionId=12345678-1234-1234-1234-1234567890ab; CertificateThumbprint=c8 4b e0 46 f6 0e 72 6b 4e 9c 28 94 a5 17 0a 21 90 55 8f 83"
    -Description "Visual Studio Load Test Client"
    -LiteralPath "C:\myvhd\VSClient.vhd"
    -Name “VSClient.vhd”
    -Location "North Central US"
  • Wait for the uploading to complete. The process may take a few hours.
  • Press Enter to start execution.
  • In the Windows Azure VHD Verification Tool dialog, click OK to allow the VHD to be mounted. If the AutoPlay dialog appears, close it.
  • Note: Initially, the tool executes a preparation phase where it mounts the VHD file and verifies it. 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 change the folder where CsUpload stores this file, use the –TempLocation parameter and then specify the path to the alternate location.
    After the preparation phase completes, the tool creates a new blob to hold the image file and then begins to upload the compressed image to our Windows Azure account.
  • Note: The VHD image files are typically large and, depending on the speed of the Internet connection, may take a significant amount of time to upload. If we stop in the middle of the upload, next time we start the process it will pick it up from where it left before.
  • In the Management Portal, select the Hosted Services, Storage Accounts & CDN tab, and then VM Images. Notice that the list includes the VSClient.vhd file that we are currently uploading and that its status is shown as Pending.
  • Wait for the upload to complete, which may take several hours. Examine the status of the VM role image in the Management Portal and verify that it has now changed to Committed.

Steps to Publish VSClient VMRole in the Cloud

1. Submit Request to participate in the VM role program

  • Go to the Windows Azure Portal and submit request to participate in the VM Role and Windows Azure Connect programs. Once your submission has been approved run the script EnableVMRole-X64 or 32 bit version. Run this script on your development Visual Studio machine on premise.

2. Created a new hosted service if you don’t have one available

3. Created an empty Windows Azure Project

  • After the VM image deployed to your Windows Azure account, you can create a service model and configure it to reference this image.
  • Start Microsoft Visual Studio 2010.
  • Click File -> New -> Project
  • Select Visual C# –> Cloud –> Windows Azure Project
  • Type the Name as MyVSClientVM and click OK
  • In the New Windows Azure Project dialog, click OK without adding any roles.

4. Add a VM role to the Azure Project

  • Once the solution is created, right-click the Roles folder inside the project, point to Add, and then select New Virtual Machine Role.

Ne-VM-role_thumb1

  • Note: If you don’t see the “New Virtual Machine Role” in the list, you can create and run one of the following .reg files to add a Windows registry entry:
      • EnableVMRole-X64.reg (for For 64 bit OS):
        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
      • EnableVMRole-x86.reg (For 32 bit OS):
        Windows Registry Editor Version 5.00
        [HKEY_CURRENT_USER\Software\Microsoft\Windows Azure Tools for Microsoft Visual Studio 2010\1.0]
        "VirtualMachineRoleEnabled"=dword:00000001

5. Configure Windows Azure Management Portal Credentials in Visual Studio

  • Double click on VM role project then select the Virtual Hard Disk tab. To show the window, expand the Roles node in Solution Explorer and then double-click the VMRole1 role.
  • In the Virtual Hard Disk tab, expand the drop down list labeled Select or create your Windows Azure account credentials, and then choose Add…
  • In the Windows Azure Project Management Authentication dialog, expand the drop down list below the label Create or select an existing certificate for authentication and choose Create.
  • In the Create Certificate dialog, set the name to AzureMgmt and click OK.
  • Now, click the link labeled Copy the full path to store the path to the certificate file in the clipboard.
  • Visual Studio stores the public key file for the certificate it generates in a temporary folder inside your local data directory. Click OK to dismiss the confirmation message box and then save the path in the clipboard to a safe location. You will need this value shortly, when you upload the certificate to the portal.
  • Now, in the Windows Azure Project Management Authentication dialog, click the link labeled Windows Azure Portal to open a browser window and navigate to the Management Portal.
  • At the Management Portal, if you have not already done so, sign in using your Windows Live ID.
  • Select the Hosted Services, Storage Accounts & CDN option, click Management Certificates, and then click Add Certificate on the ribbon.
  • In the Add New Management Certificate dialog, click Browse, change the file name to the path for 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.
  • In the Properties pane, make a record of your subscription ID. You will need it in the next step.
  • Go back to the Windows Azure Project Management Authentication dialog in Visual Studio and paste the value retrieved from the Management Portal into the subscription ID textbox.

6. Configure Virtual Hard Disk

  • Double click on VM role project then select the Virtual Hard Disk tab. To show the window, expand the Roles node in Solution Explorer and then double-click the VMRole1 role.
  • Once you configure the credentials, choose them in the drop down list labeled Select or create your Windows Azure account credentials. After you do this, Visual Studio accesses your subscription and retrieves a list of available virtual machine images.
  • Expand the drop down list labeled Select VHD and choose the image you uploaded (VSClient).

7. Configure Number of Instances and Virtual Machine Size

  • Set Instance count to 1. Set the size as large.

8. Configure Remote Desktop Connection

  • Next, configure the Remote Desktop connections for your role. To do this, right-click the MyVMRole cloud service project in Solution Explorer and select Package. In the Package Windows Azure project dialog box, click Enable Remote Desktop for all roles.
  • In the Remote Desktop Configuration dialog, choose the newly created certificate from the drop down list, enter the name of the user that you will use to connect remotely to your role–this can be any name of your choice (we use loadtestadmin) –enter a password and confirm it, and leave the account expiration date unchanged. Upon completion of the package deployment the user you entered will be created as new administrator of the hosted service. You will need to select the same user across controller and agent to be able to monitor performance metrics. Click OK to close the Remote Desktop Configuration dialog.
  • Finally, back in the Package Windows Azure project dialog, click Package and 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.

9. Publish to the cloud

  • Right click MyVMRole and select MyVMRole
  • In Common Settings, Select your Hosted service
  • Click MyVMRole

Steps to Login and Configure VSClient VMRole Instance in the Cloud

1. Connect to a Role Instance with Remote Desktop

  • Once the role’s status changes to Ready, expand the deployment in the center pane to show its instances and select the line labeled VM Instance–there should only be a single instance for the current deployment– and then click Connect on the ribbon.
  • Download the Remote Desktop connection file from the Management Portal. Depending on your browser security configuration, the browser may block the download and prompt you for confirmation. If this happens, you may need to allow the download to proceed and then repeat the previous step once the page refreshes. In the File Download dialog, click Open.
  • If prompted by a security warning from your browser, click Allow to proceed.
  • Click Connect in the Remote Desktop Connection dialog.
  • In the Windows Security dialog, enter the credentials that you specified earlier when you configured the Remote Desktop connection for the role (loadtestadmin), and then click OK.
  • Remote Desktop prompts you with a dialog warning that the identity of the remote computer cannot be verified. Click Yes to proceed.

2. Install Azure connect Local Endpoint

  • Go to the Windows Azure management portal (http://windows.azure.com) and login in.
  • Click Virtual Network, under Connect, click on your Subscription
  • Click Install Local Endpoint, click Copy Link to Clipboard, click OK
  • Start IE and Paste the clipboard on the IE address bar. The address should look similar to https://waconnecttokenpage.cloudapp.net/Default.aspx?token=12345678-1234-1234-1234-1234567890ab
    Note: make sure that to Configure IE ESC off by running Server Manager. Otherwise, it may be unable to install the endpoint.
  • Follow the wizard to run and install the local endpoint
  • Wait for a few minutes for the endpoints to show up under the azure portal under Virtual Networks/Connect/Your Subscription/Groups and Roles as Computer as shown in the Type column.
  • If the “Type” in the azure portal doesn’t show up as “Computer” for a long time then try re-installing the local endpoint software in the VMs.

3. Configure SQL Server Login for the local Windows account

  • Start SQL Server Management Studio and connect to the database with SQL Admin account sa.
  • Right click on Security/Logins and click New Login…
  • Click General page
      • For Login name: type .\loadtestadmin
      • Check Windows authentication.
  • Click Server Roles page
      • Check all the Server roles (bulkadmin, dbcreator, diskadmin, processadmin, public, securityadmin, serveradmin, setupadin, sysadmin)
  • Click User mapping page
      • Check all the maps
      • Highlight master and check db_owner role
      • Highlight model and check db_owner role
      • Highlight msdb and check db_owner role
      • Highlight ReprotServer and check db_owner role
      • Highlight ReprotServerTempDB and check db_owner role
      • Highlight temdb and check db_owner role

=========================

***************************************

=========================

Last edited Mar 2, 2012 at 8:49 PM by hanz, version 3

Comments

No comments yet.