使用 Azure 门户创建具有静态公共 IP 地址的虚拟机Create a virtual machine with a static public IP address using the Azure portal

可以创建具有静态公共 IP 地址的虚拟机。You can create a virtual machine with a static public IP address. 使用公共 IP 地址可以通过 Internet 来与虚拟机通信。A public IP address enables you to communicate to a virtual machine from the internet. 分配静态公共 IP 地址而非动态地址可以确保地址永远不会改变。Assign a static public IP address, rather than a dynamic address, to ensure that the address never changes. 详细了解静态公共 IP 地址Learn more about static public IP addresses. 若要将分配给现有虚拟机的公共 IP 地址从动态更改为静态,或者要使用专用 IP 地址,请参阅添加、更改或删除 IP 地址To change a public IP address assigned to an existing virtual machine from dynamic to static, or to work with private IP addresses, see Add, change, or remove IP addresses. 公共 IP 地址会产生少许费用,可为每个订阅使用的公共 IP 地址数有限制Public IP addresses have a nominal charge, and there is a limit to the number of public IP addresses that you can use per subscription.

登录 AzureSign in to Azure

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

创建虚拟机Create a virtual machine

  1. 选择 Azure 门户左上角的“+ 创建资源” 。Select + Create a resource found on the upper, left corner of the Azure portal.

  2. 选择“虚拟机”,然后选择“Windows Server 2016 Datacenter”或另一操作系统。 Select Virtual Machines, and then select Windows Server 2016 Datacenter, or another operating system of your choosing.

  3. 输入或选择以下信息,保留剩下的默认设置,然后选择“确定” :Enter, or select, the following information, accept the defaults for the remaining settings, and then select OK:

    设置Setting Value
    NameName myVMmyVM
    用户名User name 输入所选用户名。Enter a user name of your choosing.
    密码Password 输入所选密码。Enter a password of your choosing. 密码必须至少 12 个字符长,且符合定义的复杂性要求The password must be at least 12 characters long and meet the defined complexity requirements.
    订阅Subscription 选择订阅。Select your subscription.
    资源组Resource group 选择“使用现有资源组”,再选择“myResourceGroup” 。Select Use existing and select myResourceGroup.
    位置Location 选择“中国东部” Select China East
  4. 选择 VM 的大小,然后选择“选择” 。Select a size for the VM and then select Select.

  5. 在“设置”下选择“公共 IP 地址”。 Under Settings, select Public IP address.

  6. 输入“myPublicIpAddress”,选择“静态”,然后选择“确定”,如下图所示: Enter myPublicIpAddress, select Static, and then select OK, as shown in the following picture:

    选择“静态”

    如果公共 IP 地址必须为标准 SKU,请在“SKU”下选择“标准”。 If the public IP address must be a standard SKU, select Standard under SKU. 详细了解公共 IP 地址 SKULearn more about Public IP address SKUs. 如果虚拟机将添加到公共 Azure 负载均衡器的后端池,则虚拟机公共 IP 地址的 SKU 必须与负载均衡器的公共 IP 地址的 SKU 相匹配。If the virtual machine will be added to the back-end pool of a public Azure Load Balancer, the SKU of the virtual machine's public IP address must match the SKU of the load balancer's public IP address. 有关详细信息,请参阅 Azure 负载均衡器For details, see Azure Load Balancer.

  7. 在“选择公共入站端口”下选择一个端口,或者不选择任何端口。 Select a port, or no ports under Select public inbound ports. 选择了端口 3389,目的是能够通过 Internet 对 Windows Server 虚拟机进行远程访问。Portal 3389 is selected, to enable remote access to the Windows Server virtual machine from the internet. 对于生产型工作负荷,建议不要打开从 Internet 进行访问的端口 3389。Opening port 3389 from the internet is not recommended for production workloads.

    选择端口

  8. 接受其余默认设置,然后选择“确定” 。Accept the remaining default settings and select OK.

  9. 在“摘要” 页中,选择“创建” 。On the Summary page, select Create. 部署虚拟机需要数分钟。The virtual machine takes a few minutes to deploy.

  10. 部署虚拟机以后,请在门户顶部的搜索框中输入 myPublicIpAddressOnce the virtual machine is deployed, enter myPublicIpAddress in the search box at the top of the portal. 当“myPublicIpAddress”出现在搜索结果中时,将其选中。 When myPublicIpAddress appears in the search results, select it.

  11. 可以查看分配的公共 IP 地址,以及分配给 myVM 虚拟机的地址,如下图所示:You can view the public IP address that is assigned, and that the address is assigned to the myVM virtual machine, as shown in the following picture:

    查看公共 IP 地址

    Azure 从你在其中创建虚拟机的区域使用的地址中分配了一个公共 IP 地址。Azure assigned a public IP address from addresses used in the region you created the virtual machine in. 可以下载 Azure 中国云的范围(前缀)列表。You can download the list of ranges (prefixes) for the Azure China clouds.

  12. 选择“配置”,确认分配为“静态”。 Select Configuration to confirm that the assignment is Static.

    查看公共 IP 地址

Warning

不要修改虚拟机的操作系统中的 IP 地址设置。Do not modify the IP address settings within the virtual machine's operating system. 操作系统不知道 Azure 公共 IP 地址。The operating system is unaware of Azure public IP addresses. 虽然可以向操作系统添加专用 IP 地址设置,但除非必要,否则我们建议不要这样做,而只能阅读向操作系统添加专用 IP 地址之后才执行此操作。Though you can add private IP address settings to the operating system, we recommend not doing so unless necessary, and not until after reading Add a private IP address to an operating system.

清理资源Clean up resources

不再需要资源组时,可将资源组及其包含的所有资源一并删除:When no longer needed, delete the resource group and all of the resources it contains:

  1. 在门户顶部的“搜索”框中输入“myResourceGroup” 。Enter myResourceGroup in the Search box at the top of the portal. 当在搜索结果中看到“myResourceGroup”时,将其选中。 When you see myResourceGroup in the search results, select it.
  2. 选择“删除资源组”。 Select Delete resource group.
  3. 对于“键入资源组名称:”,输入“myResourceGroup”,然后选择“删除”。 Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete.

后续步骤Next steps