简体   繁体   English

如何使用非托管磁盘从 VHD 创建 Azure VM?

[英]How do you create Azure VM from VHD with unmanaged disk?

I have a Datacenter 2016 server with unmanaged disk.我有一个带有非托管磁盘的 Datacenter 2016 服务器。 I need to be able to replicate this VM and continue using an unmanaged disk.我需要能够复制此 VM 并继续使用非托管磁盘。

Do I need to provision the VM i want to replicate?我是否需要配置我想要复制的 VM? Or can I just use the VHD in storage to create a new VM?或者我可以只使用存储中的 VHD 来创建一个新的虚拟机吗?

Here is my powershell script so far.到目前为止,这是我的 powershell 脚本。 Note that I tried to provision a VM请注意,我尝试配置 VM

New-AzVm `
    -ResourceGroupName "myResource" `
    -Name "myVM" `
    -ImageName "" ` //IS THIS WHERE YOU WOULD PUT A VHD? 
    -Location "West US 2" `
    -VirtualNetworkName "my-vnet" `
    -SubnetName "default" `
    -SecurityGroupName "myvmNSG" `
    -OpenPorts 3389, 80, 443

If you want to create an unmanaged VM from the VHD file, you can use the VM config.如果要从 VHD 文件创建非托管 VM,可以使用 VM 配置。 Here is an example using the existing NIC and VNet, you can also create the new one for it:这是一个使用现有 NIC 和 VNet 的示例,您也可以为其创建新的:

$NIC = Get-AzNetworkInterface -ResourceGroupName charlesUnmanaged -Name azurevm938
$VirtualMachine = New-AzVMConfig -VMName "azurevm" -VMSize "Standard_DS3"
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -Name "unmanagedos" -VhdUri $OSDiskUri -CreateOption Attach -Linux
New-AzVM -ResourceGroupName "charlesUnmanaged" -Location "East US" -VM $VirtualMachine -Verbose 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM