Azure Stack Hub 托管磁盘:差异与注意事项Azure Stack Hub managed disks: differences and considerations

本文汇总了 Azure Stack Hub 中的托管磁盘Azure 中的托管磁盘之间的差异。This article summarizes the differences between managed disks in Azure Stack Hub and managed disks in Azure. 有关 Azure Stack Hub 与 Azure 之间的大致差异的详细信息,请参阅重要注意事项一文。To learn about high-level differences between Azure Stack Hub and Azure, see the Key considerations article.

托管磁盘通过管理与 VM 磁盘关联的存储帐户简化了 IaaS 虚拟机 (VM) 的磁盘管理。Managed disks simplify disk management for IaaS virtual machines (VMs) by managing the storage accounts associated with the VM disks.

使用 Azure Stack Hub 门户创建 VM 时,托管磁盘在默认情况下已启用。Managed disks are enabled by default when creating VMs using the Azure Stack Hub portal.

速查表:托管磁盘的差异Cheat sheet: managed disk differences

功能Feature Azure(中国)Azure (China) Azure Stack HubAzure Stack Hub
静态数据加密Encryption for data at rest Azure 存储服务加密 (SSE)、Azure 磁盘加密 (ADE)。Azure Storage Service Encryption (SSE), Azure Disk Encryption (ADE). BitLocker 128 位 AES 加密BitLocker 128-bit AES encryption
映像Image 托管自定义映像Managed custom image 支持Supported
备份选项Backup options Azure 备份服务Azure Backup service 尚不支持Not yet supported
灾难恢复选项Disaster recovery options Azure Site RecoveryAzure Site Recovery 尚不支持Not yet supported
磁盘类型Disk types 高级 SSD、标准 SSD 和标准 HDD。Premium SSD, Standard SSD, and Standard HDD. 高级 SSD、标准 HDDPremium SSD, Standard HDD
高级磁盘Premium disks 完全支持。Fully supported. 可部署,但无性能限制或保证Can be provisioned, but no performance limit or guarantee
高级磁盘 IOPSPremium disks IOPs 取决于磁盘大小。Depends on disk size. 每个磁盘 2300 IOPS2300 IOPs per disk
高级磁盘吞吐量Premium disks throughput 取决于磁盘大小。Depends on disk size. 每个磁盘 145 MB/秒145 MB/second per disk
磁盘大小Disk size Azure 高级磁盘:P4 (32 GiB) 到 P80 (32 TiB)Azure Premium Disk: P4 (32 GiB) to P80 (32 TiB)
Azure 标准 SSD 磁盘:E10 (128 GiB) 到 E80 (32 TiB)Azure Standard SSD Disk: E10 (128 GiB) to E80 (32 TiB)
Azure 标准 HDD 磁盘:S4 (32 GiB) 到 S80 (32 TiB)Azure Standard HDD Disk: S4 (32 GiB) to S80 (32 TiB)
M4:32 GiBM4: 32 GiB
M6:64 GiBM6: 64 GiB
M10:128 GiBM10: 128 GiB
M15:256 GiBM15: 256 GiB
M20:512 GiBM20: 512 GiB
M30:1023 GiBM30: 1023 GiB
磁盘快照复制Disks snapshot copy 支持附加到正在运行的 VM 的快照 Azure 托管磁盘。Snapshot Azure managed disks attached to a running VM supported. 尚不支持Not yet supported
磁盘性能分析Disks performance analytic 支持的聚合指标和每磁盘指标。Aggregate metrics and per disk metrics supported. 尚不支持Not yet supported
迁移Migration 提供从现有非托管 Azure 资源管理器 VM 迁移的工具,而无需重新创建 VM。Provide tool to migrate from existing unmanaged Azure Resource Manager VMs without the need to recreate the VM. 尚不支持Not yet supported

备注

Azure Stack Hub 中的托管磁盘 IOPs 和吞吐量是一个上限数字而非预配的数字,这可能会受在 Azure Stack Hub 中运行的硬件和工作负荷影响。Managed disks IOPs and throughput in Azure Stack Hub is a cap number instead of a provisioned number, which may be impacted by hardware and workloads running in Azure Stack Hub.

指标Metrics

存储指标也有一些差异:There are also differences with storage metrics:

  • 使用 Azure Stack Hub,存储指标中的事务数据不区分内部或外部网络带宽。With Azure Stack Hub, the transaction data in storage metrics does not differentiate internal or external network bandwidth.
  • 存储指标中的 Azure Stack Hub 事务数据不包含虚拟机对所装载磁盘的访问。Azure Stack Hub transaction data in storage metrics does not include virtual machine access to the mounted disks.

API 版本API versions

Azure Stack Hub 托管磁盘支持以下 API 版本:Azure Stack Hub managed disks support the following API versions:

  • 2019-03-012019-03-01

  • 2018-09-302018-09-30

  • 2018-06-012018-06-01

  • 2018-04-012018-04-01

  • 2017-03-302017-03-30

  • 2017-03-302017-03-30

  • 2017-12-01(仅限托管映像,无磁盘,无快照)2017-12-01 (Managed images only, no disks, no snapshots)

转换为托管磁盘Convert to managed disks

备注

不能在 Azure Stack Hub 中使用 Azure PowerShell cmdlet ConvertTo-AzVMManagedDisk 将非托管磁盘转换为托管磁盘。The Azure PowerShell cmdlet ConvertTo-AzVMManagedDisk cannot be used to convert an unmanaged disk to a managed disk in Azure Stack Hub. Azure Stack Hub 目前不支持此 cmdlet。Azure Stack Hub does not currently support this cmdlet.

可以使用以下脚本将当前预配的 VM 从非托管磁盘转换为托管磁盘。You can use the following script to convert a currently provisioned VM from unmanaged to managed disks. 将占位符替换为自己的值。Replace the placeholders with your own values.

$SubscriptionId = "SubId"

# The name of your resource group where your VM to be converted exists.
$ResourceGroupName ="MyResourceGroup"

# The name of the managed disk to be created.
$DiskName = "mngddisk"

# The size of the disks in GB. It should be greater than the VHD file size.
$DiskSize = "50"

# The URI of the VHD file that will be used to create the managed disk.
# The VHD file can be deleted as soon as the managed disk is created.
$VhdUri = "https://rgmgddisks347.blob.local.azurestack.external/vhds/unmngdvm20181109013817.vhd"

# The storage type for the managed disk: PremiumLRS or StandardLRS.
$AccountType = "StandardLRS"

# The Azure Stack Hub location where the managed disk will be located.
# The location should be the same as the location of the storage account in which VHD file is stored.
# Configure the new managed VM point to the old unmanaged VM configuration (network config, VM name, location).
$Location = "local"
$VirtualMachineName = "unmngdvm"
$VirtualMachineSize = "Standard_D1"
$PIpName = "unmngdvm-ip"
$VirtualNetworkName = "unmngdrg-vnet"
$NicName = "unmngdvm"

# Set the context to the subscription ID in which the managed disk will be created.
Select-AzSubscription -SubscriptionId $SubscriptionId

# Delete old VM, but keep the OS disk.
Remove-AzVm -Name $VirtualMachineName -ResourceGroupName $ResourceGroupName

# Create the managed disk configuration.
$DiskConfig = New-AzDiskConfig -AccountType $AccountType -Location $Location -DiskSizeGB $DiskSize -SourceUri $VhdUri -CreateOption Import

# Create managed disk.
New-AzDisk -DiskName $DiskName -Disk $DiskConfig -ResourceGroupName $resourceGroupName
$Disk = Get-AzDisk -DiskName $DiskName -ResourceGroupName $ResourceGroupName
$VirtualMachine = New-AzVMConfig -VMName $VirtualMachineName -VMSize $VirtualMachineSize

# Use the managed disk resource ID to attach it to the virtual machine.
# Change the OS type to "-Windows" if the OS disk has the Windows OS.
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -ManagedDiskId $Disk.Id -CreateOption Attach -Linux

# Create a public IP for the VM.
$PublicIp = Get-AzPublicIpAddress -Name $PIpName -ResourceGroupName $ResourceGroupName

# Get the virtual network where the virtual machine will be hosted.
$VNet = Get-AzVirtualNetwork -Name $VirtualNetworkName -ResourceGroupName $ResourceGroupName

# Create NIC in the first subnet of the virtual network.
$Nic = Get-AzNetworkInterface -Name $NicName -ResourceGroupName $ResourceGroupName

$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $Nic.Id

# Create the virtual machine with managed disk.
New-AzVM -VM $VirtualMachine -ResourceGroupName $ResourceGroupName -Location $Location

托管映像Managed images

Azure Stack Hub 支持托管映像,可让你在通用化 VM(非托管和托管的 VM)上创建托管映像对象,以后只能创建托管磁盘 VM。Azure Stack Hub supports managed images, which enable you to create a managed image object on a generalized VM (both unmanaged and managed) that can only create managed disk VMs going forward. 托管映像可实现以下两种方案:Managed images enable the following two scenarios:

  • 你有通用化的非托管 VM,后来想要使用托管磁盘。You have generalized unmanaged VMs and want to use managed disks going forward.
  • 你有通用化的托管 VM,并想要创建多个类似的托管 VM。You have a generalized managed VM and would like to create multiple, similar managed VMs.

步骤 1:通用化 VMStep 1: Generalize the VM

对于 Windows,请遵循使用 Sysprep 通用化 Windows VM 部分操作。For Windows, follow the Generalize the Windows VM using Sysprep section. 对于 Linux,请遵循此处所述的步骤 1。For Linux, follow step 1 here.

备注

请务必将 VM 通用化。Make sure to generalize your VM. 基于未正确通用化的映像创建 VM 会导致 VMProvisioningTimeout 错误。Creating a VM from an image that hasn't been properly generalized can produce a VMProvisioningTimeout error.

步骤 2:创建托管映像Step 2: Create the managed image

可以使用门户、PowerShell 或 CLI 创建托管映像。You can use the portal, PowerShell, or CLI to create the managed image. 请按创建托管映像中的步骤操作。Follow the steps in Create a managed image.

步骤 3:选择用例Step 3: Choose the use case

情况 1:将非托管 VM 迁移到托管磁盘Case 1: Migrate unmanaged VMs to managed disks

执行此步骤之前,请务必正确通用化 VM。Make sure to generalize your VM correctly before doing this step. 通用化之后,不再可以使用此 VM。After generalization, you can no longer use this VM. 基于未正确通用化的映像创建 VM 会导致 VMProvisioningTimeout 错误。Creating a VM from an image that hasn't been properly generalized will lead to a VMProvisioningTimeout error.

按照从使用存储帐户的 VM 创建映像中的说明,从存储帐户中的通用化 VHD 创建托管映像。Follow the instructions in Create an image from a VM that uses a storage account to create a managed image from a generalized VHD in a storage account. 将来可以使用此映像创建托管 VM。You can use this image in the future to create managed VMs.

情况 2:使用 PowerShell 基于托管映像创建托管 VMCase 2: Create managed VM from managed image using PowerShell

使用使用 PowerShell 从托管磁盘创建映像的脚本从现有托管磁盘 VM 创建映像之后,请使用以下示例脚本从现有映像对象创建类似的 Linux VM。After you create an image from an existing managed disk VM using the script in Create an image from a managed disk using PowerShell, use the following example script to create a similar Linux VM from an existing image object.

Azure Stack Hub PowerShell 模块 1.7.0 或更高版本:按从托管映像创建 VM 中的说明操作。Azure Stack Hub PowerShell module 1.7.0 or later: Follow the instructions in Create a VM from a managed image.

Azure Stack Hub PowerShell 模块 1.6.0 或更低版本:Azure Stack Hub PowerShell module 1.6.0 or earlier:

# Variables for common values
$ResourceGroupName = "MyResourceGroup"
$Location = "local"
$VirtualMachineName = "MyVM"
$ImageRG = "managedlinuxrg"
$ImageName = "simplelinuxvmm-image-2019122"

# Create credential object
$Cred = Get-Credential -Message "Enter a username and password for the virtual machine."

# Create a resource group
New-AzResourceGroup -Name $ResourceGroupName -Location $Location

# Create a subnet configuration
$SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name "MySubnet" -AddressPrefix "192.168.1.0/24"

# Create a virtual network
$VNet = New-AzVirtualNetwork -ResourceGroupName $ResourceGroupName -Location $Location `
  -Name "MyVNet" -AddressPrefix "192.168.0.0/16" -Subnet $SubnetConfig

# Create a public IP address and specify a DNS name
$PIp = New-AzPublicIpAddress -ResourceGroupName $ResourceGroupName -Location $Location `
  -Name "mypublicdns$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 4

# Create an inbound network security group rule for port 3389
$NsgRuleSSH = New-AzNetworkSecurityRuleConfig -Name "MyNetworkSecurityGroupRuleSSH"  -Protocol Tcp `
  -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
  -DestinationPortRange 22 -Access Allow

# Create a network security group
$Nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroupName -Location $Location `
  -Name "MyNetworkSecurityGroup" -SecurityRules $NsgRuleSSH

# Create a virtual network card and associate with public IP address and NSG
$Nic = New-AzNetworkInterface -Name "MyNic" -ResourceGroupName $ResourceGroupName -Location $Location `
  -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $PIp.Id -NetworkSecurityGroupId $Nsg.Id

$Image = Get-AzImage -ResourceGroupName $ImageRG -ImageName $ImageName

# Create a virtual machine configuration
$VmConfig = New-AzVMConfig -VMName $VirtualMachineName -VMSize "Standard_D1" | `
Set-AzVMOperatingSystem -Linux -ComputerName $VirtualMachineName -Credential $Cred | `
Set-AzVMSourceImage -Id $Image.Id | `
Set-AzVMOSDisk -VM $VmConfig -CreateOption FromImage -Linux | `
Add-AzVMNetworkInterface -Id $Nic.Id

# Create a virtual machine
New-AzVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VmConfig

也可以使用门户基于托管映像创建 VM。You can also use the portal to create a VM from a managed image. 有关详细信息,请参阅 Azure 托管映像文章:在 Azure 中创建通用化 VM 的托管映像从托管映像创建 VMFor more information, see the Azure-managed image articles Create a managed image of a generalized VM in Azure and Create a VM from a managed image.

配置Configuration

应用 1808 或更高版本的更新后,必须先进行以下配置更改,然后再使用托管磁盘:After applying the 1808 update or later, you must make the following configuration change before using managed disks:

  • 如果订阅是在应用 1808 更新之前创建的,请遵循以下步骤来更新订阅。If a subscription was created before the 1808 update, follow below steps to update the subscription. 否则,在此订阅中部署 VM 可能会失败,并出现错误消息“磁盘管理器发生内部错误。”Otherwise, deploying VMs in this subscription might fail with an error message "Internal error in disk manager."
    1. 在 Azure Stack Hub 用户门户中,转到“订阅”,找到相应订阅。In the Azure Stack Hub user portal, go to Subscriptions and find the subscription. 依次单击“资源提供程序”、“Microsoft.Compute”、“重新注册”。Click Resource Providers, then click Microsoft.Compute, and then click Re-register.
    2. 在同一订阅下,转到“访问控制(标识和访问管理)”,验证“Azure Stack Hub - 托管磁盘”是否已列出。 Under the same subscription, go to Access Control (IAM), and verify that Azure Stack Hub - Managed Disk is listed.
  • 如果使用多租户环境,请让云操作员(可以是组织内部或来自服务提供商的操作员)根据在 Azure Stack Hub 中配置多租户中的步骤重新配置每个来宾目录。If you use a multi-tenant environment, ask your cloud operator (who may be in your own organization, or from the service provider) to reconfigure each of your guest directories following the steps in Configure multi-tenancy in Azure Stack Hub. 否则,在与该来宾目录关联的订阅中部署 VM 可能会失败,并出现错误消息“磁盘管理器中出现内部错误。”Otherwise, deploying VMs in a subscription associated with that guest directory might fail with the error message "Internal error in disk manager."

后续步骤Next steps