By Jim White (Director of Training and instructor)
Another new feature added to Windows Azure as of the Nov 2010 release (Windows Azure SDK 1.3) is Remote Desktop. Side note: per my last post, you can see a full list of new features in the new Azure release here.
Just as you have used Windows remote desktop to gain access to a server in your data center, you can now use remote desktop to access the virtual machine running your Windows Azure role (Web, worker or the new VM role). Why remote desktop into an virtual machine running one of your roles? You use remote desktop to configure or troubleshoot your role.
Assuming you have the latest Azure SDK 1.3, here are the steps necessary to use remote desktop in Azure:
- Obtain (or create) a Personal Information Exchange certificate.
- Upload the certificate to the Hosted Service in Windows Azure.
- Using Visual Studio, publish your Azure role and configure the virtual machines for remote desktop connections (using the certificate).
- Connect to the virtual machine once the instance is deployed and running.
1. Obtain the PFX Certificate
Azure Certificates
There are a couple of types of certificate files you may need when building applications in Azure. X.509 certificates are used to authenticate operations in Windows Azure. X.509 certificates have a .cer extension. Personal Information Exchange certificates are issued by a signing authority and verifies the authenticity and security of the hosted service. Self-signed certificates can be used for testing purposes. Personal Information Exchange certificates have a .pfx extension and are therefore usually referred to as PFX certificates. Importantly, PFX are used for creating remote desktop connections. Specifically, a PFX certificate is used to encrypt the password used to obtain a remote desktop connection. See here for more details on Azure certificates.
Creating the certificate
There are a couple of ways to create a PFX certificate. You can use the makecert tool provided with the .NET Framework. Alternatively, you can use the Internet Information Services (IIS) Manager. See here for more details on creating certificates using both tools. For demonstrations purposes, let's look at the makecert tool option. Open a Visual Studio Command Prompt (make sure you do so as an administrator).
In the command prompt window, type the following command:
makecert -sky exchange -r -n "CN=[your certificate's name]" -pe -a sha1 -len
2048 -ss My "[your certificate's name].cer"
To learn more about the details and options around makecert too, take a look at the documentation here.
Exporting the certificate
With a certificat created, the next step is to export the certificate from your systems certificate store in PFX format. Again, there are a few tools you can use to export certificates to PFX format. You can either use the Certificate Manager (certmgr.msc) tool provide as part of the .NET Framework or export one from the Internet Information Services (IIS) Manager. Again, for demonstration purposes, let's look at using the Certification Manager option. Start the Certificate Manager by executing certmgr.msc in a command prompt window or in the Start menu textbox.
When the Certificate Manager starts, locate your newly created certificate under Personal > Certificates (as shown below).
Right click on your certificate in the list and select All Tasks > Export... from the menu.
A wizard will now assist you in exporting your certificate.
On the first page of the wizard, hit the Next> button. On the next page, select the Yes radio button to indicate you want to export the private key. On the next page, make sure the Personal Information Exchange format radio button is selected and then hit the Next> button. In the next page, enter the password for your private key and then save the PFX file to your designated location on the next page of the wizard (note the .pfx filename suffix). The last page summarizes your export request. When you hit the Finish button, if the export is successful, you get an appropriate message prompt.
2. Create the Hosted Service and Upload the Certificate
At this point, you are ready to create the hosted service and upload you certificate that will allow remote desktop connections. In this example, the hosted service and certificate will be created using the Windows Azure Portal.
Create the Hosted Service
Sign into the Windows Azure Portal (windows.azure.com) using your Windows Live ID (assuming you have a Windows Azure account). Once logged in, request to create a new hosted service. When you create the hosted service in Azure, you are not yet deploying code into the cloud. You just need to create the hosted service shell to hold the new certificate. So, when you create the service, make sure you select the "Do not deploy" radio button (shown below) on the Create a New Hosted Service entry form.
Upload the certificate
With the hosted service created (but the application role(s) not yet deployed), upload the certificate you created in step 1. In the Hosted Services listing, click on the Certificates folder listed under your new hosted service and then click on the Add Certificate button that displays on the top of the portal page (see example below).
You will be prompted to supply the certificate file and private key password.
When you browse to the location of the certificate in your filesystem, you will notice the portal UI constrains your selection to .pfx file types.
Once you select your PFX file and enter your password, it takes only a few seconds for the Windows Azure Portal to create and associate you certificate to your hosted service. The certificate should now be listed under Certificates for the hosted service.
3. Create the Role(s) and configure the Virtual Machine
Create your Cloud Project
Now the Azure host environment is prepped for remote desktop enabled roles. The next task is to create your role(s) and configure the virtual machine instances than run those roles for remote desktop connections. For example sake, I created a new cloud project (DemoRemoteDesktop) with a single Web role (DemoWebRole).
Once your application has been constructed and tested and is ready to be deployed, right click on the cloud project and request to Publish... the project from the resulting menu (just as you normally would for any Azure Cloud application).
When the Deploy Windows Azure project window comes up, select/enter your hosted service credentials, deployment environment (the new hosted service you just created in the last step), the deployment label and then, importantly, click on the "Configure Remote Desktop connection" link shown at the bottom of the window (see below).
Configure Remote Desktop Configuration
In the prompt that results, check the "Enable connection for all roles" checkbox. Then select the certificate used for the remote connection (the same certificate you created as part of step 1).
Complete the entries in the Remote Desktop Configuration dialog. Enter the username and password that you want to use to authenticate when you make a remote desktop connections into the virtual machine that will host your role(s). The password must meet certain complexity requirements (it must contain a combination of capital letters, lower case letters, and numbers or symbols - the window will tell you if your password does not comply). Also indicate the account expiration date. After this date specified, remote desktop connections will be blocked. This allows deployers/administrators to establish a small window of time whereby developers can remote in and configure/check on the roles, but then lock them out after things are running properly.
Hit the OK button on the Remote Desktop Configuration dialog window and then again on the Deploy Windows Azure project window to complete the deployment.
Make a Remote Desktop Connection
As always, it takes Visual Studio and Azure a few minutes to deploy and start your role(s). Once your role(s) is up and running, you should now be able to remote desktop into the virtual machine running your instance(s). First, you might notice that if you click on your roles listed in the Hosted Services display, the Azure portal indicates those that are are remote-desktop enabled via the Remote Access icons and indicators now enabled at the top of the page (see below).
You can use the Enable checkbox to instantly turn off remote desktop connections. Use the configure button to change the username, password, expiration time or certificate used as part of the connection.
When you click on one of the remote-desktop-enabled role instances, the Connect icon becomes enabled in the portal display.
You might be wondering why you have to select a role instance? Remember, you make a remote desktop connection to a virtual machine running a role and there may be (and probably will be) several instances for any role. Pick the instance whose virtual machine you want to connect.
To make a remote desktop connection, having picked one of the role instances, simply click the Connect icon in the portal icon bar at the top of the display. This causes a few pop-ups to appear. First a File Download popup (the Remote Desktop Connection file) appears. Push the Open button on this prompt.
Next comes a security warning. Push the Connect button on this prompt (since your certificate is not signed).
Finally, you are prompted to sign-in to the virtual machine through the Windows Security popup. Enter the username and password you created in step 3 above (when you configured your role for remote desktop connections) and press OK to login remotely. Importantly, when you first login, proceed your username with a "\" indicating no Domain (as shown below).
A final security alert window requires you acknowledge the warning by pushing the Yes button.
Once authenticated, you should be be provided with a remote desktop screen just as if you connected to server in your data center. The tip off that you are connected to Azure can be seen both in the remote desktop window's label (note the GUID and URL) and the background image that indicates the copy of Windows "is not genuine".
Wrap Up
So, as you can see, most of the work in getting remote desktop connections into Azure virtual machines is in creating and uploading the required certificate. For more information about Azure and remote desktop, see the MSDN site. If you are just starting out in Windows Azure, consider taking Intertech's Complete Windows Azure class. If your team needs help implementing an Azure solution, contact Ryan McCabe (Intertech's account representative for Azure) at rmccabe@intertech.com. Finally, I also encourage you to register with the Virtual Azure User Group (azureug.net). We meet monthly in virtual space and share our knowledge and experiences on Azure.
9621703a-8a4c-4d97-aa20-378c071d1b21|2|5.0