Set Up a Remote Desktop Connection for a Role in Azure
Updated: December 5, 2013
After you create a cloud service that is running your application, you can remotely access a role instance in that application to configure settings or troubleshoot issues. How you set up a remote desktop connection depends on the type of role instance that you are using and the environment you are working in.
The following information can help you set up and use a remote desktop connection:
Set up a remote desktop connection for web roles or worker roles
Set up a remote desktop connection for Virtual Machines
Access instances of web roles, worker roles, or Virtual Machines
To enable a remote desktop connection for a web role or worker role, you can set up the connection in the service model for the application, or you can use the Azure Management Portal to set up the connection after the instances are running.
The Imports element must be added to the service definition file that imports the RemoteAccess module and the RemoteForwarder module into the service model. When you create an Azure project by using Visual Studio, the files for the service model are created for you.
The service model consists of a ServiceDefinition.csdef file and a ServiceConfiguration.cscfg file. The definition file is packaged with the role binaries when the application for the cloud service is prepared for deployment. The ServiceConfiguration.cscfg file is deployed with the application package and is used by Azure to determine how the application should run. For more information about the ServiceDefinition.csdef file, see Set Up a Cloud Service for Azure. For more information about creating a project, see Creating a Windows Azure Project with Visual Studio.
After you create your project, you can enable a remote desktop connection by using the information in Using Remote Desktop with Windows Azure Roles.
After you configure the connection, the service definition file should be similar to the following example with the Imports element added.
<ServiceDefinition name="<name-of-cloud-service>" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0"> <WebRole name="WebRole1" vmsize="Small"> <Sites> <Site name="Web"> <Bindings> <Binding name="Endpoint1" endpointName="Endpoint1" /> </Bindings> </Site> </Sites> <Endpoints> <InputEndpoint name="Endpoint1" protocol="http" port="80" /> </Endpoints> <Imports> <Import moduleName="Diagnostics" /> <Import moduleName="RemoteAccess" /> <Import moduleName="RemoteForwarder" /> </Imports> </WebRole> </ServiceDefinition>
The service configuration file should be similar to the following example with the values that you provided when you set up the connection:
<?xml version="1.0" encoding="utf-8"?> <ServiceConfiguration serviceName="<name-of-cloud-service>" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0"> <Role name="WebRole1"> <Instances count="2" /> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="<name-of-user-account>" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="<base-64-encrypted-password>" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="<certificate-expiration>" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" /> </ConfigurationSettings> <Certificates> <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="<certificate-thumbprint>" thumbprintAlgorithm="sha1" /> </Certificates> </Role> </ServiceConfiguration>
When you package and publish the application, you must ensure that the Enable Remote Desktop for all Roles check box is selected. For more information, see Publishing a Cloud Service using the Azure Tools.
To enable a remote desktop connection for a Virtual Machine, an input endpoint must be added to the machine that specifies the port to use for the connection. You can set up an input endpoint by using the Management Portal. For more information, see How to Set Up Endpoints to a Virtual Machine. You can also add an input endpoint when you programmatically create the machine by using the Service Management REST APIs. For more information, see the InputEndpoints element in Create Virtual Machine Deployment.
To access instances of web roles, worker roles, or Virtual Machines, you must use a remote desktop protocol (RDP) file. You can download the file from the Management Portal or you can programmatically retrieve the file.
You can use the following steps to retrieve the RDP file from the Management Portal and then use Remote Desktop Connection to connect to the instance using the file:
On the Instances page, select the instance, and then click Connect on the command bar.
Click Save to save the remote desktop protocol file to your local computer.
Open Remote Desktop Connection, click Show Options, and then click Open.
Browse to the location where you saved the RDP file, select the file, click Open, and then click Connect. Follow the instructions to complete the connection.
You can use the Get-AzureRemoteDesktopFile cmdlet to retrieve the RDP file. For more information, see Log on to a Virtual Machine by using a Remote Desktop Connection.
In Visual Studio, you can use the Server Explorer to create a remote desktop connection.
In Server Explorer, expand the Azure Compute node or the Azure Virtual Machines node.
Complete one of the following:
For web roles or worker roles, expand the cloud service node, expand the role node, right-click an instance node, click Connect using Remote Desktop, and then enter the user name and password.
For Virtual Machines, right-click the Virtual Machine node, click Connect using Remote Desktop, and then enter the user name and password.
- For web roles or worker roles, expand the cloud service node, expand the role node, right-click an instance node, click Connect using Remote Desktop, and then enter the user name and password.