将 Azure 托管映像从 Azure Commercial 复制到 Azure 中国

Copy Azure Managed Image from Azure Comercial to Azure China

我们有一个从 Azure 中的 Windows VM 构建的自定义托管映像。我们需要将该托管映像复制到中国并从中创建虚拟机。不幸的是,我们无法连接到从复制的 .vhd 创建的 VM。我们做的步骤: 1. 从自定义托管映像在欧洲创建 VM。 2. 运行 系统准备。 3. 导出Managed Disk,上传.vhd到中国的Storage Account。 4. 从该映像创建 VM。 问题是我们无法通过 RDP 连接到该虚拟机。 正确的做法是什么? (连接超时) 我们不能在中国重新创建那个形象,因为我们需要那个形象与我们在欧洲的形象保持一致。

通用 VHD 已使用 Sysprep 删除了您的所有个人帐户信息。如果您打算使用 VHD 作为映像来创建新的 VM。您应该创建一个新的用户名和密码以用作本地管理员帐户。

以下 PowerShell 脚本显示了如何设置虚拟机配置并将上传的 VM 映像用作新安装的源。

    # Enter a new user name and password to use as the local administrator account 
    # for remotely accessing the VM.
    $cred = Get-Credential

    # Name of the storage account where the VHD is located. This example sets the 
    # storage account name as "myStorageAccount"
    $storageAccName = "myStorageAccount"

    # Name of the virtual machine. This example sets the VM name as "myVM".
    $vmName = "myVM"

    # Size of the virtual machine. This example creates "Standard_D2_v2" sized VM. 
    # See the VM sizes documentation for more information: 
    # https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/
    $vmSize = "Standard_D2_v2"

    # Computer name for the VM. This examples sets the computer name as "myComputer".
    $computerName = "myComputer"

    # Name of the disk that holds the OS. This example sets the 
    # OS disk name as "myOsDisk"
    $osDiskName = "myOsDisk"

    # Assign a SKU name. This example sets the SKU name as "Standard_LRS"
    # Valid values for -SkuName are: Standard_LRS - locally redundant storage, Standard_ZRS - zone redundant
    # storage, Standard_GRS - geo redundant storage, Standard_RAGRS - read access geo redundant storage,
    # Premium_LRS - premium locally redundant storage. 
    $skuName = "Standard_LRS"

    # Get the storage account where the uploaded image is stored
    $storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $rgName -AccountName $storageAccName

    # Set the VM name and size
    $vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize

    #Set the Windows operating system configuration and add the NIC
    $vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName `
        -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
    $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id

    # Create the OS disk URI
    $osDiskUri = '{0}vhds/{1}-{2}.vhd' `
        -f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName

    # Configure the OS disk to be created from the existing VHD image (-CreateOption fromImage).
    $vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri `
        -CreateOption fromImage -SourceImageUri $imageURI -Windows

    # Create the new VM
    New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm

参考:Upload a generalized VHD to Azure to create a new VM