簡體   English   中英

追溯地將現有虛擬機加入VNet(Azure)

[英]Retroactively joining existing VMs to a VNet (Azure)

我在Azure中配置了兩個經典VM。 它們存在於不同的資源組中,現在我想將它們加入VNet。 我怎么做? 我找不到與此相關的文檔,並且由於我的應用程序處於活動狀態,所以我希望最大限度地減少停機時間(或最好完全消除停機時間)。

您的VM在不同的“資源”組中,我寧願說您的VM在傳統的VM中在不同的雲服務中。 您沒有在說它們是否在同一網絡中,所以我假設它們在不同的vNet中。 在這種情況下,無需將VM遷移到其他雲服務。 您只需要將VM的vNet之一更改為與另一虛擬機相同的vNet。

您可以使用powershell腳本輕松地做到這一點-

$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 

如果您的VM是ARM VM,也可以使用其他方法。 請參閱此問題-http://stackoverflow.com/questions/39388871/move-a-microsoft-azure-vm-to-a-different-subnet-within-a-vnet/39419368#39419368

無法 現有 VM移至VNET。 雖然,您可以做一些事情。

您可以刪除/刪除現有VM / VM,這樣做將留下VM / VM的VHD / VHD。 現在,您可以繼續使用相同的VHD創建新的VM。

話雖如此,無法將已經創建的VM移至VNET。 VM可以在創建時加入VNET。

希望這可以幫助!

問候,普里揚卡

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM