快速入门:在 Azure 门户中创建 Windows 虚拟机Quickstart: Create a Windows virtual machine in the Azure portal

可以通过 Azure 门户创建 Azure 虚拟机 (VM)。Azure virtual machines (VMs) can be created through the Azure portal. 此方法提供基于浏览器的用户界面来创建 VM 及其相关资源。This method provides a browser-based user interface to create VMs and their associated resources. 本快速入门展示了如何使用 Azure 门户在 Azure 中部署运行 Windows Server 2019 的虚拟机 (VM)。This quickstart shows you how to use the Azure portal to deploy a virtual machine (VM) in Azure that runs Windows Server 2019. 若要查看运行中的 VM,可以通过 RDP 登录到该 VM 并安装 IIS Web 服务器。To see your VM in action, you then RDP to the VM and install the IIS web server.

如果没有 Azure 订阅,请在开始前创建一个试用版订阅If you don't have an Azure subscription, create a trial subscription before you begin.

登录 AzureSign in to Azure

通过 https://portal.azure.cn 登录到 Azure 门户。Sign in to the Azure portal at https://portal.azure.cn.

创建虚拟机Create virtual machine

  1. 在搜索中键入“虚拟机”。Type virtual machines in the search.

  2. 在“服务”下,选择“虚拟机” 。Under Services, select Virtual machines.

  3. 在“虚拟机”页中,选择“添加”,然后选择“虚拟机” 。In the Virtual machines page, select Add then Virtual machine.

  4. 在“基本信息”标签页中的“项目详细信息”下,确保选择了正确的订阅,然后选择“新建资源组”。In the Basics tab, under Project details, make sure the correct subscription is selected and then choose to Create new resource group. 对于名称,请键入 myResourceGroupType myResourceGroup for the name.


    通过 Azure 门户、PowerShell 或 CLI 创建任何 Azure 资源时,除了原始资源命名约定之外,我们还应遵循以下限制。When you create any Azure resource through the Azure Portal, PowerShell, or CLI, we should follow the below restriction in additional except for the original resource naming conventions.

    指定的所有参数中的任何字符都应设置为英文字符。Any character in all parameters you specified should be included in the English characters set.

    如果参数中有任何非英语字符(如中文字符),相应的调用可能会出现错误。When there are any None English characters in parameter, such as Chinese characters, the corresponding invoke may be run into error.

    “项目详细信息”部分的屏幕截图,显示为虚拟机选择 Azure 订阅和资源组的位置

  5. 在“实例详细信息”下,对于“虚拟机名称”键入“myVM”,对于“区域”选择“中国东部”。Under Instance details, type myVM for the Virtual machine name and choose China East for your Region. 对于“映像”,请选择“Windows Server 2019 Datacenter”;对于“大小”,请选择“Standard_DS1_v2”。Choose Windows Server 2019 Datacenter for the Image and Standard_DS1_v2 for the Size. 保留其他默认值。Leave the other defaults.


  6. 在“管理员帐户”下,提供用户名(例如 azureuser)和密码。Under Administrator account, provide a username, such as azureuser and a password. 密码必须至少 12 个字符长,且符合定义的复杂性要求The password must be at least 12 characters long and meet the defined complexity requirements.


  7. 在“入站端口规则”下,选择“允许所选端口”,然后从下拉列表中选择“RDP (3389)”和“HTTP (80)” 。Under Inbound port rules, choose Allow selected ports and then select RDP (3389) and HTTP (80) from the drop-down.


  8. 保留其余默认值,然后选择页面底部的“查看 + 创建”按钮。Leave the remaining defaults and then select the Review + create button at the bottom of the page.


  9. 运行验证之后,请选择页面底部的“创建”按钮。After validation runs, select the Create button at the bottom of the page.

  10. 在部署完成之后,选择“转到资源”。After deployment is complete, select Go to resource.



    Azure 为未获得公共 IP 地址或位于内部基本 Azure 负载均衡器后端池中的 Azure 虚拟机提供临时 IP。Azure provides an ephemeral IP for Azure Virtual Machines which aren't assigned a public IP address, or are in the backend pool of an internal Basic Azure Load Balancer. 临时 IP 机制可提供无法配置的出站 IP 地址。The ephemeral IP mechanism provides an outbound IP address that isn't configurable.

    如果将公共 IP 地址分配给某个虚拟机或将该虚拟机置入具有或不具有出站规则的标准负载均衡器的后端池中时,将禁用其原有的临时 IP。The ephemeral IP is disabled when a public IP address is assigned to the virtual machine or the virtual machine is placed in the backend pool of a Standard Load Balancer with or without outbound rules. 如果向虚拟机的子网分配 Azure 虚拟网络 NAT 网关资源,也会禁用其临时 IP。If a Azure Virtual Network NAT gateway resource is assigned to the subnet of the virtual machine, the ephemeral IP is disabled.

    有关 Azure 中出站连接的详细信息,请参阅为出站连接使用源网络地址转换 (SNAT)For more information on outbound connections in Azure, see Using Source Network Address Translation (SNAT) for outbound connections.

连接到虚拟机Connect to virtual machine

创建与虚拟机的远程桌面连接。Create a remote desktop connection to the virtual machine. 这些说明指明了如何从 Windows 计算机连接到 VM。These directions tell you how to connect to your VM from a Windows computer. 在 Mac 上,需要一个 RDP 客户端,例如 Mac 应用商店提供的这个远程桌面客户端On a Mac, you need an RDP client such as this Remote Desktop Client from the Mac App Store.

  1. 在虚拟机的概述页上,选择“连接”按钮,然后选择“RDP” 。On the overview page for your virtual machine, select the Connect button then select RDP.


  2. 在“使用 RDP 进行连接”页面中,保留默认选项,以使用 IP 地址通过端口 3389 进行连接,然后单击“下载 RDP 文件” 。In the Connect with RDP page, keep the default options to connect by IP address, over port 3389, and click Download RDP file.

  3. 打开下载的 RDP 文件,然后在出现提示时单击“连接”。Open the downloaded RDP file and click Connect when prompted.

  4. 在“Windows 安全性”窗口中,依次选择“更多选择”、“使用其他帐户”。In the Windows Security window, select More choices and then Use a different account. 以“localhost\username”的形式键入用户名,输入为虚拟机创建的密码,然后单击“确定”。Type the username as localhost\username, enter the password you created for the virtual machine, and then click OK.

  5. 你可能会在登录过程中收到证书警告。You may receive a certificate warning during the sign-in process. 单击“是”或“继续”以创建连接。 Click Yes or Continue to create the connection.

安装 Web 服务器Install web server

若要查看运行中的 VM,请安装 IIS Web 服务器。To see your VM in action, install the IIS web server. 在 VM 中打开 PowerShell 提示符并运行以下命令:Open a PowerShell prompt on the VM and run the following command:

Install-WindowsFeature -name Web-Server -IncludeManagementTools

完成后,关闭到 VM 的 RDP 连接。When done, close the RDP connection to the VM.

查看 IIS 欢迎页View the IIS welcome page

在门户中选择 VM,并在 VM 的概述中将鼠标指针悬停在 IP 地址上,以显示“复制到剪贴板”。In the portal, select the VM and in the overview of the VM, hover over the IP address to show Copy to clipboard. 复制 IP 地址并粘贴到浏览器选项卡。此时会打开默认的 IIS 欢迎页,如下所示:Copy the IP address and paste it into a browser tab. The default IIS welcome page will open, and should look like this:

浏览器中的 IIS 默认站点的屏幕截图

清理资源Clean up resources

当不再需要时,可以删除资源组、虚拟机和所有相关资源。When no longer needed, you can delete the resource group, virtual machine, and all related resources.

转到虚拟机的资源组,然后选择“删除资源组”。Go to the resource group for the virtual machine, then select Delete resource group. 确认资源组名称,以完成资源删除。Confirm the name of the resource group to finish deleting the resources.

后续步骤Next steps

在本快速入门中,你部署了简单的虚拟机,打开了 Web 流量的网络端口,并安装了基本的 Web 服务器。In this quickstart, you deployed a simple virtual machine, opened a network port for web traffic, and installed a basic web server. 若要深入了解 Azure 虚拟机,请继续学习 Windows VM 教程。To learn more about Azure virtual machines, continue to the tutorial for Windows VMs.