Azure 中的 Windows 虛擬機器概觀Overview of 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 之前應該的事項、建立方式及管理方式的相關資訊。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 讓您能夠有彈性地進行虛擬化,而不需購買並維護執行它的實體硬體。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,而當您不需要時便關閉這些 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

命名Naming

虛擬機器指派一個名稱給它,而它設定一個電腦名稱作為作業系統的一部分。A virtual machine has a name assigned to it and it has a computer name configured as part of the operating system. VM 的名稱最多可為 15 個字元。The name of a VM can be up to 15 characters.

如果您使用 Azure 來建立作業系統磁碟,則電腦名稱和虛擬機器名稱為相同。If you use Azure to create the operating system disk, the computer name and the virtual machine name are the same. 如果您上傳並使用您自己的映像 (該映像包含先前所設定的作業系統),並用它來建立虛擬機器,則名稱可能會不同。If you upload and use your own image that contains a previously configured operating system and use it to create a virtual machine, the names can be different. 我們建議您,當您上傳自己的映像檔時,將作業系統中的電腦名稱設為與虛擬機器的名稱相同。We recommend that when you upload your own image file, you make the computer name in the operating system and the virtual machine name the same.

位置Locations

Azure 中所建立的所有資源分散在世界各地的多個地理區域All resources created in Azure are distributed across multiple geographical regions around the world. 通常,當您建立 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.

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 提供許多 Marketplace 映像來與不同版本和類型的 Windows Server 作業系統搭配使用。Azure provides many marketplace images to use with various versions and types of Windows Server operating systems. Marketplace 映像是依映像發行者、供應項目、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. 如需所支援客體作業系統、角色和功能的詳細資訊,請參閱 Microsoft Azure 虛擬機器的 Microsoft 伺服器軟體支援For more information on the supported guest operating systems, roles, and features, see Microsoft server software support for Microsoft 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.

擴充功能Extensions

VM 擴充會透過 post 部署設定及自動化工作為您的 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 可以有公用 IP 位址指派給 VM,以從遠端存取它。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.

如何建立第一個 VM?How do I create my first VM?

有幾個選擇可供您建立 VM。You have several choices for creating your VM. 您所做的選擇取決於您所在的環境。The choice that you make depends on the environment you are in.

下表提供協助您開始建立 VM 的資訊。This table provides information to get you started creating your VM.

方法Method 文章Article
Azure 入口網站Azure portal 使用入口網站建立執行 Windows 的虛擬機器Create a virtual machine running Windows using the portal
範本Templates 利用 Resource Manager 範本建立 Windows 虛擬機器Create a Windows virtual machine with a Resource Manager template
Azure PowerShellAzure PowerShell 使用 PowerShell 建立 Windows VMCreate a Windows VM using PowerShell
用戶端 SDKClient SDKs 使用 C# 部署 Azure 資源Deploy Azure Resources using C#
REST APIREST APIs 建立或更新 VMCreate or update a VM
Azure CLIAzure CLI 使用 Azure CLI 建立 VMCreate a VM with the Azure CLI

您希望它絕對不會發生,但偶爾會發生錯誤。You hope it never happens, but occasionally something goes wrong. 如果您發生這種情況,請查看疑難排解在 Azure 中建立 Windows 虛擬機器時發生的 Resource Manager 部署問題中的資訊。If this situation happens to you, look at the information in Troubleshoot Resource Manager deployment issues with creating a Windows virtual machine in Azure.

如何管理我所建立的 VM?How do I manage the VM that I created?

可以使用以瀏覽器為基礎的入口網站、支援指令碼處理的命令列工具,或直接透過 API 管理 VM。VMs can be managed using a browser-based portal, command-line tools with support for scripting, or directly through APIs. 您可能會執行的一些一般管理工作為取得 VM 的相關資訊、登入 VM、管理可用性,以及進行備份。Some typical management tasks that you might perform are getting information about a VM, logging on to a VM, managing availability, and making backups.

取得 VM 的相關資訊Get information about a VM

下表顯示您可以取得 VM 相關資訊的一些方式。This table shows you some of the ways that you can get information about a VM.

方法Method 描述Description
Azure 入口網站Azure portal 在 [中樞] 功能表中,按一下 [虛擬機器] ,然後從清單中選取 VM。On the hub menu, click Virtual Machines and then select the VM from the list. 在 VM 的刀鋒視窗上,您可存取概觀資訊、設定值,並監視度量。On the blade for the VM, you have access to overview information, setting values, and monitoring metrics.
Azure PowerShellAzure PowerShell 如需使用 PowerShell 來管理 VM 的相關資訊,請參閱使用 Azure PowerShell 模組來建立和管理 Windows VMFor information about using PowerShell to manage VMs, see Create and manage Windows VMs with the Azure PowerShell module.
REST APIREST API 使用取得 VM 資訊作業來取得 VM 的相關資訊。Use the Get VM information operation to get information about a VM.
用戶端 SDKClient SDKs 如需使用 C# 來管理 VM 的相關資訊,請參閱使用 Azure Resource Manager 和 C# 來管理 Azure 虛擬機器For information about using C# to manage VMs, see Manage Azure Virtual Machines using Azure Resource Manager and C#.
Azure CLIAzure CLI 如需使用 Azure CLI 管理 VM 的詳細資訊,請參閱 Azure CLI 參考For information about using Azure CLI to manage VMs, see Azure CLI Reference.

登入 VMLog on to the VM

您使用 Azure 入口網站中的 [連線] 按鈕啟動遠端桌面 (RDP) 工作階段You use the Connect button in the Azure portal to start a Remote Desktop (RDP) session. 嘗試使用遠端連線時,有時可能會出錯。Things can sometimes go wrong when trying to use a remote connection. 如果您發生這種情況,請參閱疑難排解遠端桌面連線至執行 Windows 的 Azure 虛擬機器中的說明資訊。If this situation happens to you, check out the help information in Troubleshoot Remote Desktop connections to an Azure virtual machine running Windows.

管理可用性Manage availability

請務必了解如何確保應用程式的高可用性It’s important for you to understand how to ensure high availability for your application. 此組態需要建立多個 VM 以確保至少有一個 VM 正在執行。This configuration involves creating multiple VMs to ensure that at least one is running.

為了讓您的部署符合 99.95 的 VM 服務等級協定資格,您必須部署兩個或更多在可用性設定組內執行工作負載的 VM。In order for your deployment to qualify for our 99.95 VM Service Level Agreement, you need to deploy two or more VMs running your workload inside an availability set. 此組態可確保您的 VM 會分散多個容錯網域,且部署至具有不同維護期間的主機。This configuration ensures your VMs are distributed across multiple fault domains and are deployed onto hosts with different maintenance windows. 完整 Azure SLA 說明保證的 Azure 整體可用性。The full Azure SLA explains the guaranteed availability of Azure as a whole.

備份 VMBack up the VM

復原服務保存庫可用來保護 Azure 備份和 Azure Site Recovery 服務中的資料和資產。A Recovery Services vault is used to protect data and assets in both Azure Backup and Azure Site Recovery services. 您可以使用復原服務保存庫,使用 PowerShell 部署和管理 Resource Manager 部署之 VM 的備份You can use a Recovery Services vault to deploy and manage backups for Resource Manager-deployed VMs using PowerShell.

後續步驟Next steps