为 Azure 云服务中的角色设置远程桌面连接Enable Remote Desktop Connection for a Role in Azure Cloud Services

可以通过远程桌面访问在 Azure 中运行的角色的桌面。Remote Desktop enables you to access the desktop of a role running in Azure. 也可以使用远程桌面连接,在应用程序正在运行时排查和诊断其问题。You can use a Remote Desktop connection to troubleshoot and diagnose problems with your application while it is running.

可以在开发过程中通过在服务定义中加入远程桌面模块来在角色中启用远程桌面连接,也可以通过远程桌面扩展选择启用远程桌面。You can enable a Remote Desktop connection in your role during development by including the Remote Desktop modules in your service definition or you can choose to enable Remote Desktop through the Remote Desktop Extension. 首选方法是使用远程桌面扩展,因为即使在部署应用程序后,也能启用远程桌面,而不必重新部署应用程序。The preferred approach is to use the Remote Desktop extension as you can enable Remote Desktop even after the application is deployed without having to redeploy your application.

从 Azure 门户配置远程桌面Configure Remote Desktop from the Azure portal

Azure 门户使用远程桌面扩展方法,即使在部署应用程序之后,也能启用远程桌面。The Azure portal uses the Remote Desktop Extension approach so you can enable Remote Desktop even after the application is deployed. 使用云服务的“远程桌面”设置,可以启用远程桌面,更改用于连接虚拟机的本地 Administrator 帐户、身份验证使用的证书,以及设置到期日期。The Remote Desktop settings for your cloud service allows you to enable Remote Desktop, change the local Administrator account used to connect to the virtual machines, the certificate used in authentication and set the expiration date.

  1. 单击“云服务”,再选择云服务的名称,然后选择“远程桌面”。Click Cloud Services, select the name of the cloud service, and then select Remote Desktop.

    云服务远程桌面

  2. 选择希望为单个角色还是所有角色启用远程桌面,并将切换器的值更改为“已启用” 。Choose whether you want to enable Remote Desktop for an individual role or for all roles, then change the value of the switcher to Enabled.

  3. 填写所需的字段:用户名、密码、到期时间和证书。Fill in the required fields for user name, password, expiry, and certificate.

    云服务远程桌面

    警告

    当首次启用远程桌面并选择“确定”(选中标记)时,所有角色实例会重新启动。 为避免重新启动,必须对于此角色安装用于对密码进行加密的证书。 如果要避免重新启动,请 上传云服务的证书 ,并返回到此对话框。

  4. 在“角色”中,选择要更新的角色,或选择“全部”以选择所有角色。In Roles, select the role you want to update or select All for all roles.

  5. 完成配置更新后,选择“保存”。When you finish your configuration updates, select Save. 角色实例需要一些时间才能准备好接收连接。It will take a few moments before your role instances are ready to receive connections.

远程到角色实例Remote into role instances

为角色启用远程桌面后,可以直接从 Azure 门户启动连接:Once Remote Desktop is enabled on the roles, you can initiate a connection directly from the Azure Portal:

  1. 单击“实例”,打开“实例”设置。Click Instances to open the Instances settings.

  2. 选择一个配置了远程桌面的角色实例。Select a role instance that has Remote Desktop configured.

  3. 单击“连接” 下载角色实例的 RDP 文件。Click Connect to download an RDP file for the role instance.

    云服务远程桌面

  4. 依次单击“打开”和“连接”,以启动远程桌面连接。Click Open and then Connect to start the Remote Desktop connection.

备注

如果云服务位于 NSG 后,可能需要创建允许端口338920000 上的流量的规则。 远程桌面使用端口 3389。 云服务实例经过负载均衡,因此无法直接控制要连接到哪个实例。 RemoteForwarder 和 RemoteAccess 代理管理 RDP 流量,允许客户端发送 RDP cookie 和指定要连接到的单个实例。 RemoteForwarder 和 RemoteAccess 代理要求打开端口 20000*(如果具有 NSG,此端口可能已被阻止)。

其他资源Additional resources

如何配置云服务How to Configure Cloud Services