【问题标题】:Copy Azure Managed Image from Azure Comercial to Azure China将 Azure 托管映像从 Azure Commercial 复制到 Azure 中国
【发布时间】:2018-10-23 21:08:07
【问题描述】:

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

【问题讨论】:

    标签: azure azure-virtual-machine azure-vm-scale-set azure-managed-disk azure-china


    【解决方案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
    

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

    【讨论】:

    • 所以,我使用与以前完全相同的 VHD 运行脚本,并且它工作正常。谢谢!之前,我使用 ARM 模板部署了 VM,RDP 甚至没有询问我的用户名和密码(ARM 模板不是创建那个吗?)并且只是超时。你会碰巧知道为什么它不能与 ARM 模板一起使用吗?我用过这个github.com/Azure/azure-quickstart-templates/tree/master/…
    • 该模板中没有凭据信息。我认为您可能需要在该模板中添加您的 credential parameters
    猜你喜欢
    • 1970-01-01
    • 2019-10-05
    • 2021-05-25
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 2020-07-12
    • 2021-05-20
    相关资源
    最近更新 更多