快速入门:在 Azure 门户中创建 Windows 虚拟机

适用于:✔️ Windows VM

可以通过 Azure 门户创建 Azure 虚拟机 (VM)。 此方法提供基于浏览器的用户界面来创建 VM 及其相关资源。 本快速入门展示了如何使用 Azure 门户在 Azure 中部署运行 Windows Server 2019 的虚拟机 (VM)。 若要查看运行中的 VM,可以通过 RDP 登录到该 VM 并安装 IIS Web 服务器。

如果没有 Azure 订阅,请在开始前创建一个试用版订阅

登录 Azure

登录到 Azure 门户

创建虚拟机

  1. 在搜索框中输入“虚拟机”。

  2. 在“服务”下,选择“虚拟机” 。

  3. 在“虚拟机”页上,选择“创建”。 此时将打开“创建虚拟机”页。

  4. 在“实例详细信息”下,输入“myVM”作为“虚拟机名称”,然后选择“Windows Server 2022 Datacenter: Azure Edition - x64 Gen 2”作为“映像”。 保留其他默认值。

    Screenshot of the Instance details section where you provide a name for the virtual machine and select its region, image and size.

    注意

    现在,某些用户将看到在多个区域创建 VM 的选项。 若要了解有关这项新功能的详细信息,请参阅在可用性区域中创建虚拟机Screenshot showing that you have the option to create virtual machines in multiple availability zones.

  5. 在“管理员帐户”下提供用户名(例如 azureuser)和密码。 密码必须至少 12 个字符长,且符合定义的复杂性要求

    Screenshot of the Administrator account section where you provide the administrator username and password

  6. 在“入站端口规则”下,选择“允许所选端口”,然后从下拉列表中选择“RDP (3389)”和“HTTP (80)” 。

    Screenshot of the inbound port rules section where you select what ports inbound connections are allowed on

  7. 保留其余默认值,然后选择页面底部的“查看 + 创建”按钮

    Screenshot showing the Review + create button at the bottom of the page.

  8. 运行验证之后,请选择页面底部的“创建”按钮。 Screenshot showing that validation has passed. Select the Create button to create the VM.

  9. 在部署完成之后,选择“转到资源”。

    Screenshot showing the next step of going to the resource.

连接到虚拟机

创建与虚拟机的远程桌面连接。 这些说明指明了如何从 Windows 计算机连接到 VM。 在 Mac 上,需要一个 RDP 客户端,例如 Mac 应用商店提供的这个远程桌面客户端

  1. 在虚拟机的概览页面上,选择“连接”“RDP”。

    Screenshot of the virtual machine overview page showing the location of the connect button.

  2. 在“使用 RDP 进行连接”选项卡中,保留默认选项,以使用 IP 地址通过端口 3389 进行连接,然后单击“下载 RDP 文件”。

    Screenshot showing the remote desktop settings and the Download RDP file button.

  3. 打开下载的 RDP 文件,然后在出现提示时单击“连接”。

  4. 在“Windows 安全性”窗口中,依次选择“更多选择”、“使用其他帐户”。 以“localhostusername”的形式键入用户名,输入为虚拟机创建的密码,然后单击“确定”。

  5. 你可能会在登录过程中收到证书警告。 单击“是”或“继续”以创建连接。

安装 Web 服务器

若要查看运行中的 VM,请安装 IIS Web 服务器。 在 VM 中打开 PowerShell 提示符并运行以下命令:

Install-WindowsFeature -name Web-Server -IncludeManagementTools

完成后,关闭到 VM 的 RDP 连接。

查看 IIS 欢迎页

在门户中选择 VM,并在 VM 的概述中将鼠标指针悬停在 IP 地址上,以显示“复制到剪贴板”。 复制 IP 地址并粘贴到浏览器选项卡。此时会打开默认的 IIS 欢迎页,如下所示:

Screenshot of the IIS default site in a browser

清理资源

当不再需要时,可以删除资源组、虚拟机和所有相关资源。

  1. 在 VM 的概述页面上,选择“资源组”链接。
  2. 在资源组页面的顶部,选择“删除资源组”。
  3. 此时将打开一个页面,警告即将删除资源。 输入资源组的名称并选择“删除”,完成资源和资源组的删除。

后续步骤

在本快速入门中,你部署了简单的虚拟机,打开了 Web 流量的网络端口,并安装了基本的 Web 服务器。 若要深入了解 Azure 虚拟机,请继续学习 Windows VM 教程。