我们有一个从 Azure 中的 Windows VM 构建的自定义托管映像。我们需要将该托管映像复制到中国并从中创建虚拟机。不幸的是,我们无法连接到从复制的 .vhd 创建的虚拟机。我们执行的步骤: 1. 从自定义托管映像在欧洲创建 VM。2. 运行 Sysprep。3. 导出托管磁盘,并将.vhd 上传到中国的Storage Account。4. 从该映像创建 VM。问题是我们无法 RDP 到该 VM。正确的方法是什么?(连接超时)我们无法在中国重新创建该图像,因为我们需要该图像与我们在欧洲的图像保持一致。
问问题
224 次
1 回答
1
通用 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
于 2018-10-24T02:21:45.830 回答