azure - 将 Azure 托管映像从 Azure 商业复制到 Azure 中国
问题描述
我们有一个从 Azure 中的 Windows VM 构建的自定义托管映像。我们需要将该托管映像复制到中国并从中创建虚拟机。不幸的是,我们无法连接到从复制的 .vhd 创建的虚拟机。我们执行的步骤: 1. 从自定义托管映像在欧洲创建 VM。2. 运行 Sysprep。3. 导出托管磁盘,并将.vhd 上传到中国的Storage Account。4. 从该映像创建 VM。问题是我们无法 RDP 到该 VM。正确的方法是什么?(连接超时)我们无法在中国重新创建该图像,因为我们需要该图像与我们在欧洲的图像保持一致。
解决方案
通用 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
推荐阅读
- c++ - 来自 QGridLayout 的 QWidgets 不会占用所有空间
- apache-spark - Spark Kafka 数据消费包
- python - Jupyter 笔记本小部件
- discord - Discord.js 计时器,定期更新倒计时
- javascript - 如何通过提示乘以输入的数字?
- java - Doxygen 在尝试修补“修补输出文件”时崩溃,出现“错误:写入图 1 时出现问题!”
- amazon-web-services - 使用 jenkins 管道中的 helm 图表在 AWS 中部署应用程序
- elasticsearch - 搜索弹性引擎不断让代码被杀死。我如何解决它?
- php - mysql中的查询有效,但是当分配给php中的变量时没有给出结果
- python - 无法为 Tensorflow RNN 模型创建可重现的结果