将Microsoft Azure VM移动到vNet中的其他子网

时间:2016-09-08 10:44:27

标签: azure azure-virtual-machine azure-cloud-services azure-virtual-network azureportal

我们不能使用天蓝色新门户网站或天蓝色经典门户网站将Microsoft Azure VM移动到vNet中的不同子网吗?如果不能通过门户网站然后怎么做呢?那么如何在创建后编辑VM的属性,比如移动到不同的子网等,?

3 个答案:

答案 0 :(得分:6)

可以通过新门户网站。首先,我想问你是使用经典VM还是资源管理器VM。如果您使用的是最后一个,则可以通过更改配置设置轻松切换子网。 转到您的网络接口>配置并点击Nic名称(见下图)

View nic Azure

将打开一个新选项卡,您可以更改nic的子网。

Change Subnet

答案 1 :(得分:1)

如果您的虚拟机是经典的,使用azure powershell cmdlet将其移动到不同的vNet非常容易。这是代码 -

$vmName  = "xxxxx"
$srcServiceName  = "xxxxx"
$newVNet = "xxxxx"

# export vm config file
$workingDir = (Get-Location).Path
$sourceVm = Get-AzureVM –ServiceName $srcServiceName –Name $vmName
$global:vmConfigurationPath = $workingDir + "\exportedVM.xml"
$sourceVm | Export-AzureVM -Path $vmConfigurationPath

# remove vm keeping the vhds and spin new vm using old configuration file but in a  new vNet
Remove-azurevm –ServiceName $srcServiceName –Name $vmName
$vmConfig = Import-AzureVM -Path $vmConfigurationPath 
New-AzureVM -ServiceName $srcServiceName  -VMs $vmConfig -VNetName $newVNet -WaitForBoot

答案 2 :(得分:0)

  

如果不可能通过门户网站然后怎么做呢?那么如何在创建后编辑VM的属性,比如移动到不同的子网等,?

可以使用Powershell完成。简而言之,它包含3个步骤:

  1. 获取VM(NIC)配置
  2. 编辑VM(NIC)配置
  3. 更新已修改的配置
  4. 注意:不支持在不同VNET之间移动VM。要将VM移动到另一个VNET,现在唯一的解决方案是使用相同的vhd文件重新创建VM。

    以下是一个很好的分步指南:

    How to change Subnet and Virtual Network for Azure Virtual Machines (ASM & ARM)

相关问题