Azure 中的 Windows 虚拟机Windows virtual machines in Azure

Azure 虚拟机 (VM) 是 Azure 提供的多种可缩放按需分配计算资源之一。Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. 通常情况下,如果需要以更大的力度(相对于其他控制选项)控制计算环境,则应选择 VM。Typically, you choose a VM when you need more control over the computing environment than the other choices offer. 本文介绍创建 VM 之前的注意事项,以及 VM 的创建方法和管理方式。This article gives you information about what you should consider before you create a VM, how you create it, and how you manage it.

使用 Azure VM 可以灵活进行虚拟化,而无需购买和维护运行 VM 的物理硬件。An Azure VM gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it. 不过,仍然需要通过执行任务来维护 VM,例如,配置、修补和安装在 VM 上运行的软件。However, you still need to maintain the VM by performing tasks, such as configuring, patching, and installing the software that runs on it.

可通过多种方式使用 Azure 虚拟机。Azure virtual machines can be used in various ways. 一些示例如下:Some examples are:

  • 开发和测试 – 在 Azure VM 上,可以快速轻松地创建具有特定配置的计算机来满足编程和应用程序测试的需要。Development and test - Azure VMs offer a quick and easy way to create a computer with specific configurations required to code and test an application.
  • 云中的应用程序 – 由于应用程序的需求会不断变化,在 Azure 中的 VM 上运行应用程序可能会节省成本。Applications in the cloud - Because demand for your application can fluctuate, it might make economic sense to run it on a VM in Azure. 使用 VM 时,需要支付额外的费用;关闭 VM 时,则无需付费。You pay for extra VMs when you need them and shut them down when you don't.
  • 扩展的数据中心 – Azure 虚拟网络中的虚拟机可以轻松连接到组织的网络。Extended datacenter - Virtual machines in an Azure virtual network can easily be connected to your organization's network.

应用程序使用的 VM 数可根据你的需要纵向扩展和横向扩展为任意数目。The number of VMs that your application uses can scale up and out to whatever is required to meet your needs.

在创建 VM 之前需要考虑哪些因素?What do I need to think about before creating a VM?

在 Azure 中构建应用程序基础结构时,始终要考虑多种设计注意事项There are always a multitude of design considerations when you build out an application infrastructure in Azure. 在开始之前,必须考虑到 VM 的以下重要方面:These aspects of a VM are important to think about before you start:

  • 应用程序资源的名称The names of your application resources
  • 资源的存储位置The location where the resources are stored
  • VM 的大小The size of the VM
  • 可以创建的 VM 的数目上限The maximum number of VMs that can be created
  • VM 运行的操作系统The operating system that the VM runs
  • VM 在启动后的配置The configuration of the VM after it starts
  • VM 所需的相关资源The related resources that the VM needs


在 Azure 中创建的所有资源分布在中国的多个地理区域All resources created in Azure are distributed across multiple geographical regions around China. 创建 VM 时, 区域通常称为“位置”。Usually, the region is called location when you create a VM. 位置指定 VM 虚拟硬盘的存储位置。For a VM, the location specifies where the virtual hard disks are stored.

下表显示了获取可用位置列表的一些方法。This table shows some of the ways you can get a list of available locations.

方法Method 说明Description
Azure 门户Azure portal 创建 VM 时,可从列表中选择位置。Select a location from the list when you create a VM.
Azure PowerShellAzure PowerShell 使用 Get-AzLocation 命令。Use the Get-AzLocation command.
REST APIREST API 使用 列出位置 操作。Use the List locations operation.
Azure CLIAzure CLI 使用 az account list-locations 操作。Use the az account list-locations operation.


Azure 宣布了行业领先的单实例虚拟机服务级别协议:可用性达到 99.9%(前提是为所有磁盘使用高级存储部署 VM)。Azure announced an industry leading single instance virtual machine Service Level Agreement of 99.9% provided you deploy the VM with premium storage for all disks. 为了使部署符合标准 99.95% 的 VM 服务级别协议,仍需要在可用性集中部署两个或更多个运行工作负荷的 VM。In order for your deployment to qualify for the standard 99.95% VM Service Level Agreement, you still need to deploy two or more VMs running your workload inside of an availability set. 可用性集可确保 VM 分布在 Azure 数据中心内的多个容错域,并使用不同的维护时段部署到主机。An availability set ensures that your VMs are distributed across multiple fault domains in the Azure data centers as well as deployed onto hosts with different maintenance windows. 完整 Azure SLA 说明了 Azure 作为整体的保证可用性。The full Azure SLA explains the guaranteed availability of Azure as a whole.

VM 大小VM size

VM 的大小由所要运行的工作负荷决定。The size of the VM that you use is determined by the workload that you want to run. 然后,所选大小又会影响多个因素,例如处理能力、内存和存储容量。The size that you choose then determines factors such as processing power, memory, and storage capacity. Azure 提供各种大小来支持多种类型的用途。Azure offers a wide variety of sizes to support many types of uses.

Azure 根据 VM 的大小和操作系统按小时进行收费Azure charges an hourly price based on the VM's size and operating system. 对于不足一小时的部分,Azure 仅根据使用的分钟数计费。For partial hours, Azure charges only for the minutes used. 存储将另行定价和收费。Storage is priced and charged separately.

VM 限制VM Limits

订阅附带默认的配额限制,在为项目部署大量 VM 时,这些限制可能会造成影响。Your subscription has default quota limits in place that could impact the deployment of many VMs for your project. 每个订阅的当前限制是每区域 20 个 VM。The current limit on a per subscription basis is 20 VMs per region. 可以开具支持票证来请求提高限制Limits can be raised by filing a support ticket requesting an increase

操作系统磁盘和映像Operating system disks and images

虚拟机使用虚拟硬盘 (VHD) 来存储其操作系统 (OS) 和数据。Virtual machines use virtual hard disks (VHDs) to store their operating system (OS) and data. VHD 还可用于存储映像,可以选择某个映像来安装 OS。VHDs are also used for the images you can choose from to install an OS.

Azure 提供许多市场映像来配合各种版本和类型的 Windows Server 操作系统使用。Azure provides many marketplace images to use with various versions and types of Windows Server operating systems. 市场映像由映像发布者、产品、SKU 和版本(通常指定为最新版本)标识。Marketplace images are identified by image publisher, offer, sku, and version (typically version is specified as latest). 仅支持 64 位操作系统。Only 64-bit operating systems are supported. 有关受支持的来宾操作系统、角色和功能的详细信息,请参阅 Azure 虚拟机的 Microsoft 服务器软件支持For more information on the supported guest operating systems, roles, and features, see Microsoft server software support for Azure virtual machines.

下表显示了查找映像信息的一些方法。This table shows some ways that you can find the information for an image.

方法Method 说明Description
Azure 门户Azure portal 选择要使用的映像时,系统会自动指定值。The values are automatically specified for you when you select an image to use.
Azure PowerShellAzure PowerShell Get-AzVMImagePublisher -Location locationGet-AzVMImagePublisher -Location location
Get-AzVMImageOffer -Location location -Publisher publisherNameGet-AzVMImageOffer -Location location -Publisher publisherName
Get-AzVMImageSku -Location location -Publisher publisherName -Offer offerNameGet-AzVMImageSku -Location location -Publisher publisherName -Offer offerName
REST APIREST APIs 列出映像发布者List image publishers
列出映像产品List image offers
列出映像 SKUList image skus
Azure CLIAzure CLI az vm image list-publishers --location locationaz vm image list-publishers --location location
az vm image list-offers --location location --publisher publisherNameaz vm image list-offers --location location --publisher publisherName
az vm image list-skus --location location --publisher publisherName --offer offerNameaz vm image list-skus --location location --publisher publisherName --offer offerName

可以选择 上传并使用自己的映像 ,在这种情况下,无需使用发布者名称、产品和 SKU。You can choose to upload and use your own image and when you do, the publisher name, offer, and sku aren't used.


VM 扩展通过部署后的配置和自动化任务来增加 VM 的功能。VM extensions give your VM additional capabilities through post deployment configuration and automated tasks.

可以使用扩展完成以下常见任务:These common tasks can be accomplished using extensions:

VM 使用下表中的资源,创建 VM 时,这些资源必须存在,否则要予以创建。The resources in this table are used by the VM and need to exist or be created when the VM is created.

资源Resource 必选Required 说明Description
资源组Resource group Yes VM 必须包含在资源组中。The VM must be contained in a resource group.
存储帐户Storage account Yes VM 需要使用存储帐户来存储其虚拟硬盘。The VM needs the storage account to store its virtual hard disks.
虚拟网络Virtual network Yes VM 必须是虚拟网络的成员。The VM must be a member of a virtual network.
公共 IP 地址Public IP address No 可以向 VM 分配一个公共 IP 地址,以便远程访问它。The VM can have a public IP address assigned to it to remotely access it.
网络接口Network interface Yes VM 需要使用网络接口在网络中通信。The VM needs the network interface to communicate in the network.
数据磁盘Data disks No VM 可以包含数据磁盘,以便扩展存储功能。The VM can include data disks to expand storage capabilities.

后续步骤Next steps

创建第一个 VM!Create your first VM!