Azure Stack Hub VM 简介Introduction to Azure Stack Hub VMs

Azure Stack Hub 以按需可缩放的计算资源的形式提供虚拟机 (VM)。Azure Stack Hub offers virtual machines (VMs) as a type of on-demand and scalable computing resource. 如果需要以更大的力度控制计算环境,可以选择 VM。You can choose a VM when you need more control over the computing environment. 本文详细介绍了如何创建第一个 VM。This article provides details about creating your first VM.

Azure Stack Hub VM 可提供虚拟化的灵活性,而无需管理群集或单个计算机。An Azure Stack Hub VM gives you the flexibility of virtualization without the need to manage clusters or individual machines. 不过,仍然需要通过执行任务(例如,配置、修补/更新和安装在 VM 上运行的软件)来维护 VM。However, you still need to maintain the VM by doing tasks such as configuring, patching/updating, and installing the software that runs on it.

可通过多种方式使用 Azure Stack Hub VM。You can use Azure Stack Hub VMs in several ways. 例如:For example:

  • 开发和测试 :Azure Stack Hub VM 可让你使用编写和测试应用程序所需的特定配置创建计算机。Development and test : Azure Stack Hub VMs enable you to create a computer with a specific configuration required to code and test an application.

  • 云中的应用程序 :由于应用程序的需求会不断变化,在 Azure Stack Hub 中的 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 Stack Hub. 使用 VM 时,需要支付额外的费用;关闭 VM 时,则无需付费。You pay for extra VMs when you need them and shut them down when you don't.

  • 扩展的数据中心 :Azure Stack Hub 虚拟网络中的 VM 可以连接到组织的网络或 Azure。Extended datacenter : VMs in an Azure Stack Hub virtual network can be connected to your organization's network, or to Azure.

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

创建 VM 之前Before creating a VM

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

  • 应用程序资源的名称。The names of your application resources.
  • 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.

名称Names

VM 会被指定名称,也具有在操作系统中所配置的计算机名称。A VM 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 Stack Hub 创建操作系统磁盘,则计算机名称与 VM 名称相同。If you use Azure Stack Hub to create the operating system disk, the computer name and the VM name are the same. 如果上传并使用自己的映像(该映像包含先前配置的操作系统),并使用它创建 VM,则名称可能会不同。If you upload and use your own image that contains a previously configured operating system and use it to create a VM, the names may be different. 上传自己的映像文件时,最佳做法是确保操作系统中的计算机名称与 VM 名称匹配。When you upload your own image file, as a best practice make sure the computer name in the operating system matches the VM name.

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 Stack Hub 提供各种大小来支持多种类型的用途。Azure Stack Hub offers different kinds of sizes to support many types of uses.

VM 限制VM limits

订阅设有默认的配额限制,可能会影响如何部署项目的 VM。Your subscription has default quota limits in place that can impact the deployment of VMs for your project. 每个订阅的当前限制是每区域 20 个 VM。The current limit on a per subscription basis is 20 VMs per region.

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

Azure Stack Hub 中的 VM 限制为第 1 代虚拟硬盘 (VHD/VHDX) 格式。VMs in Azure Stack Hub are limited to the generation 1 virtual hard disk (VHD/VHDX) format. VHD 可用来存储计算机操作系统 (OS) 和数据。VHDs can be used to store the machine operating system (OS) and data. VHD 还可用于存储安装 OS 时使用的映像。VHDs are also used for the images you use to install an OS. Azure Stack Hub 提供一个市场,适用于各种版本和类型的操作系统。Azure Stack Hub provides a marketplace to use with various versions and types of operating systems. 市场映像由映像发布者、套餐、SKU 和版本(通常将最新版本指定为 最新 )标识。Marketplace images are identified by image publisher, offer, SKU, and version (typically the latest version is specified as latest ).

下表显示了如何查找映像的信息:The following table shows how to find the information for an image:

方法Method 说明Description
Azure Stack Hub 门户Azure Stack Hub portal 选择要使用的映像时,系统会自动指定值。The values are automatically specified for you when you select an image to use.
Azure Stack Hub PowerShellAzure Stack Hub PowerShell Get-AzVMImagePublisher -Location "location"
Get-AzVMImageOffer -Location "location" -Publisher "publisherName"
Get-AzVMImageSku -Location "location" -Publisher "publisherName" -Offer "offerName"
REST APIREST APIs 列出映像发布者List image publishers
列出映像产品List image offers
列出映像 SKUList image SKUs

可以选择上传并使用自己的映像。You can choose to upload and use your own image. 如果这样做,则不会使用发布者名称、套餐和 SKU。If you do, the publisher name, offer, and SKU aren't used.

扩展Extensions

VM 扩展通过部署后配置和自动化任务来增加 VM 功能。VM extensions give your VM additional capabilities through post-deployment configuration and automated tasks. 可以使用扩展完成以下常见任务:You can accomplish these common tasks using extensions:

  • 运行自定义脚本 :预配 VM 时,自定义脚本扩展可以通过运行脚本,帮助在 VM 上配置工作负荷。Run custom scripts : The Custom Script extension helps you to configure workloads on the VM by running your script when the VM is provisioned.

  • 部署和管理配置 :可以借助 PowerShell Desired State Configuration (DSC) 扩展在 VM 上设置用于管理配置和环境的 DSC。Deploy and manage configurations : The PowerShell Desired State Configuration (DSC) extension helps you set up DSC on a VM to manage configurations and environments.

  • 收集诊断数据 :Azure 诊断扩展可帮助你配置 VM 来收集诊断数据,用于监视应用程序的运行状况。Collect diagnostics data : The Azure Diagnostics extension helps you configure the VM to collect diagnostics data that can be used to monitor the health of your application.

下表中的资源由 VM 使用,在创建 VM 时必须存在或已创建:The resources in the following 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 No 如果使用托管磁盘,则 VM 不需要存储帐户来存储其虚拟硬盘。The VM doesn't need the storage account to store its virtual hard disks if using managed 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.
LinuxNetwork 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.

创建第一个 VMCreate your first VM

有多种方法可创建 VM。There are several ways to create a VM. 你的选择取决于环境。Your choice depends on your environment. 下表提供信息来帮助你开始创建 VM:The following table provides information to help get you started creating your VM:

方法Method 文章Article
Azure Stack Hub 门户Azure Stack Hub portal 使用 Azure Stack Hub 门户创建 Windows VMCreate a Windows VM with the Azure Stack Hub portal.
使用 Azure Stack Hub 门户创建 Linux VMCreate a Linux VM using the Azure Stack Hub portal.
模板Templates Azure Stack Hub 快速入门模板位于以下位置:Azure Stack Hub Quickstart templates are located at:
https://github.com/Azure/AzureStack-QuickStart-Templates
PowerShellPowerShell 在 Azure Stack Hub 中使用 PowerShell 创建 Windows VMCreate a Windows VM by using PowerShell in Azure Stack Hub
在 Azure Stack Hub 中使用 PowerShell 创建 Linux VMCreate a Linux VM by using PowerShell in Azure Stack Hub
CLICLI 在 Azure Stack Hub 中使用 CLI 创建 Windows VMCreate a Windows VM by using CLI in Azure Stack Hub
在 Azure Stack Hub 中使用 CLI 创建 Linux VMCreate a Linux VM by using CLI in Azure Stack Hub

管理 VMManage your VM

可以使用基于浏览器的门户、支持脚本的命令行工具或直接通过 API 管理 VM。You can manage VMs using a browser-based portal, command-line tools with support for scripting, or directly through APIs. 一些典型的管理任务包括:Some typical management tasks are:

  • 获取有关 VM 的信息。Getting information about a VM.
  • 连接到 VM。Connecting to a VM.
  • 管理可用性。Managing availability.
  • 进行备份。Making backups.

获取有关 VM 的信息Get information about your VM

下表显示了可获取 VM 相关信息的一些方法:The following table shows some of the ways you can get information about a VM:

方法Method 说明Description
Azure Stack Hub 门户Azure Stack Hub portal 在中心菜单中,单击“虚拟机”,然后从列表中选择 VM。On the hub menu, click Virtual Machines and then select the VM from the list. 在 VM 的页面上,可以访问概述信息、设置值以及监视指标。On the page for the VM, you have access to overview information, setting values, and monitoring metrics.
Azure PowerShellAzure PowerShell 在 Azure 和 Azure Stack Hub 中,管理 VM 的方法很相似。Managing VMs is similar in Azure and Azure Stack Hub. 若要详细了解如何使用 PowerShell,请参阅 Azure 主题:使用 Azure PowerShell 模块创建和管理 Windows VMFor more information about using PowerShell, see the Azure topic Create and Manage Windows VMs with the Azure PowerShell module.
客户端 SDKClient SDKs 在 Azure 和 Azure Stack Hub 中,使用 C# 管理 VM 的方法很相似。Using C# to manage VMs is similar in Azure and Azure Stack Hub. 有关详细信息,请参阅 使用 c # 在 Azure 中创建和管理 Windows vmFor more information, see Create and manage Windows VMs in Azure using C#.

连接到 VMConnect to your VM

在 Azure Stack Hub 门户中,可以使用“连接”选项连接到 VM。You can use the Connect option in the Azure Stack Hub portal to connect to your VM.

后续步骤Next steps