如何將同一 VNET 下的虛擬機從經(jīng)典部署模型遷移到 Azure Resource Manager

適用場景

用戶擁有多個云服務(wù)但是在同一個 VNET 下,希望將這些虛擬機從經(jīng)典部署模型(以下簡稱:ASM)遷移到 Azure Resource Manager(以下簡稱:ARM)。

Note

如果您未使用 VNET,希望將同一個云服務(wù)下的虛擬機從 ASM 模式遷移到 ARM 模式,您可以參考這篇文章:如何將同一個云服務(wù)下的虛擬機從 ASM 遷移到 ARM 上

解決方案

首先,我們登陸到需要遷移的虛擬機所在的訂閱下,注冊遷移服務(wù):

PowerShell

#登陸到需要遷移的虛擬機所在的訂閱下PS C:\windows\system32>Login-AzureRmAccount–Environment AzureChinaCloudEnvironment? ? ? ? ? : AzureChinaCloudAccount? ? ? ? ? ? ? : XXX@mcpod.partner.onmschina.cnTenantId? ? ? ? ? ? ? :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxSubscriptionId? ? ? ? :xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxSubscriptionName? ? ? : <訂閱名稱>CurrentStorageAccount :#如果您需要遷移某個特定訂閱下的虛擬機,需要手動進行指定PS C:\windows\system32>Select-AzureRmSubscription–SubscriptionName"<訂閱名稱>"#注冊遷移服務(wù)PS C:\windows\system32>Register-AzureRmResourceProvider-ProviderNamespaceMicrosoft.ClassicInfrastructureMigrate#遷移服務(wù)注冊一般需要 5 鐘左右,您可以通過下述命令查看完成情況,PS C:\windows\system32>Get-AzureRmResourceProvider-ProviderNamespaceMicrosoft.ClassicInfrastructureMigrateProviderNamespace : Microsoft.ClassicInfrastructureMigrateRegistrationState : RegisteredResourceTypes? ? : {classicInfrastructureResources}Locations? ? ? ? : {China North, China East}Note:注冊遷移服務(wù)為一次性操作,注冊完成后以后遷移時無需再次注冊,但是如果您在未注冊前嘗試遷移,會收到報錯說該訂閱未注冊遷移服務(wù)#最后登陸到經(jīng)典模式中需要遷移的虛擬機所在訂閱下PS C:\windows\system32>Add-AzureAccount-EnvironmentAzureChinaCloudId? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Type Subscriptions? ? ? ? ? ? ? ? ? ? ? ? Tenants--------------------------XXX@mcpod.partner.onmschina.cn Userxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }#如果您需要遷移某個特定訂閱下的虛擬機,需要手動進行指定Select-AzureSubscription–SubscriptionName"<訂閱名稱>"

檢查 ARM 下您訂閱里的配額,確保需要遷移的虛擬機有足夠的配額可以使用:

#您可以根據(jù)虛擬機所在的區(qū)域選擇 China North 或者 China East

PS C:\windows\system32> Get-AzureRmVMUsage -Location "China East"

Name? ? ? ? ? ? ? ? ? ? ? ? ? ? Current Value Limit? Unit

----? ? ? ? ? ? ? ? ? ? ? ? ? ? ------------- -----? ----

Availability Sets? ? ? ? ? ? ? ? ? ? ? ? ? ? 2? 2000 Count

Total Regional Cores? ? ? ? ? ? ? ? ? ? ? ? 39? 100 Count

Virtual Machines? ? ? ? ? ? ? ? ? ? ? ? ? ? 17 10000 Count

Virtual Machine Scale Sets? ? ? ? ? ? ? ? ? 1? 2000 Count

Standard Dv2 Family Cores? ? ? ? ? ? ? ? ? ? 4? 100 Count

Standard FS Family Cores? ? ? ? ? ? ? ? ? ? 16? 100 Count

Standard A0-A7 Family Cores? ? ? ? ? ? ? ? 11? 100 Count

Standard D Family Cores? ? ? ? ? ? ? ? ? ? ? 1? 100 Count

Standard Av2 Family Cores? ? ? ? ? ? ? ? ? ? 2? 100 Count

Standard DSv2 Family Cores? ? ? ? ? ? ? ? ? 4? 100 Count

Standard DS Family Cores? ? ? ? ? ? ? ? ? ? 1? 100 Count

Basic A Family Cores? ? ? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard A8-A11 Family Cores? ? ? ? ? ? ? ? 0? 100 Count

Standard G Family Cores? ? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard GS Family Cores? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard F Family Cores? ? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard NV Family Cores? ? ? ? ? ? ? ? ? ? 0? ? 0 Count

Standard NC Family Cores? ? ? ? ? ? ? ? ? ? 0? ? 0 Count

Standard H Family Cores? ? ? ? ? ? ? ? ? ? ? 0? ? 0 Count

Standard LS Family Cores? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard Dv2 Promo Family Cores? ? ? ? ? ? ? 0? 100 Count

Standard DSv2 Promo Family Cores? ? ? ? ? ? 0? 100 Count

Standard MS Family Cores? ? ? ? ? ? ? ? ? ? 0? ? 0 Count

Standard Dv3 Family Cores? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard DSv3 Family Cores? ? ? ? ? ? ? ? ? 0? 100 Count

Standard Ev3 Family Cores? ? ? ? ? ? ? ? ? ? 0? 100 Count

Standard ESv3 Family Cores? ? ? ? ? ? ? ? ? 0? 100 Count

Standard Storage Managed Disks? ? ? ? ? ? ? 0 10000 Count

Premium Storage Managed Disks? ? ? ? ? ? ? ? 0 10000 Count

將同一個 VNET 下的虛擬機從 ASM 遷移到 ARM 上

PowerShell

#將 ASM 下 VNET 的名稱賦值給變量方便后面調(diào)用PS C:\windows\system32>$vnetName=""#驗證 VNET 是否符合遷移條件PS C:\windows\system32>Move-AzureVirtualNetwork-Validate-VirtualNetworkName$vnetNameOperationId? ? ? ? :7faa1832-931c-44f9-81b8-68cfa4a4aeedResult? ? ? ? ? ? : Validation Passed with warnings. Please see ValidationMessages objectfora list of resources? ? ? ? ? ? ? ? that will be migrated and additional detail on the warnings.ValidationMessages : {test4as, test01, test01, test01...}#檢查驗證中的告警信息PS C:\windows\system32>$validate=Move-AzureVirtualNetwork-Validate-VirtualNetworkName$vnetNamePS C:\windows\system32>$validate.ValidationMessagesResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : VM <虛擬機名稱>inDeployment <資源組名稱> within Cloud Service <云服務(wù)名稱> is eligibleformigration.VirtualMachineName : <虛擬機名稱>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機名稱>inHostedService <云服務(wù)名稱> contains Extension BGInfo version1.* which is an XML? ? ? ? ? ? ? ? extension. XML extensions are not supportedinAzure Resource Manager. It is recommended to? ? ? ? ? ? ? ? uninstall it from the VM. Alternatively, it will be automatically uninstalled during migration.VirtualMachineName : <虛擬機名稱>ResourceType? ? ? : VirtualNetworkResourceName? ? ? : Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Virtual Network is eligibleformigration.VirtualMachineName :ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Deployment <資源組名稱>inCloud Service <云服務(wù)名稱> is eligibleformigration.VirtualMachineName :ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : VM <虛擬機名稱>inDeployment <資源組名稱> within Cloud Service <云服務(wù)名稱> is eligibleformigration.VirtualMachineName : <虛擬機名稱>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機名稱>inHostedService <云服務(wù)名稱> contains Extension BGInfo version1.* which is an XML? ? ? ? ? ? ? ? extension. XML extensions are not supportedinAzure Resource Manager. It is recommended to? ? ? ? ? ? ? ? uninstall it from the VM. Alternatively, it will be automatically uninstalled during migration.VirtualMachineName : <虛擬機名稱>#上述驗證通過后接下來執(zhí)行遷移準(zhǔn)備操作PS C:\windows\system32>Move-AzureVirtualNetwork-Prepare-VirtualNetworkName$vnetNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus

Move-AzureVirtualNetwork 8470416e-987f-4171-9e3f-65263a99e41d Succeeded

如果在遷移準(zhǔn)備操作中出現(xiàn)了報錯,或者您想取消本次遷移操作,可以使用下面命令進行取消

PS C:\windows\system32> Move-AzureVirtualNetwork -Abort -VirtualNetworkName $vnetName

OperationDescription OperationId OperationStatus

Move-AzureVirtualNetwork fde6fc72-7cb8-4cb5-a6e0-01a519509e18 Succeeded

如果遷移準(zhǔn)備步驟操作成功,那么可以執(zhí)行下述命令來生效遷移操作

PS C:\windows\system32> Move-AzureVirtualNetwork -Commit -VirtualNetworkName $vnetName

OperationDescription OperationId OperationStatus

Move-AzureVirtualNetwork 1ce54778-bbcf-403d-b971-a13993484212 Succeeded

遷移虛擬機所在的存儲賬號

PowerShell

#檢查存儲賬號下是否有未被遷移的虛擬機的 VHD 存在PS C:\windows\system32>$storageAccountName="<存儲賬號名稱>"PS C:\windows\system32>Get-AzureDisk|where-Object{$_.MediaLink.Host.Contains($storageAccountName)} |Select-Object-ExpandPropertyAttachedTo-Property`>>? DiskName |Format-List-PropertyRoleName, DiskName#檢查存儲賬號下是否有已分離的虛擬機磁盤,如有需要進行刪除,如果您仍然需要這些磁盤可以將其復(fù)制到其他存儲賬號中PS C:\windows\system32>Get-AzureDisk|where-Object{$_.MediaLink.Host.Contains($storageAccountName)} |Where-Object-PropertyAttachedTo-EQ$null|Format-List-Property DiskNameDiskName : disktest#刪除磁盤PS C:\windows\system32>Remove-AzureDisk-DiskName"disktest"OperationDescription OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Remove-AzureDisk9661659d-3bcf-4e6e-bdc4-cce7c8d7a1e0 Succeeded#刪除存儲賬號中 OS 盤和數(shù)據(jù)盤中的虛擬機鏡像PS C:\windows\system32>Get-AzureVmImage|Where-Object{$_.OSDiskConfiguration.MediaLink-ne$null-and$_.OSDiskConfiguration.MediaLink.Host.Contains($storageAccountName)`>>? ? ? ? ? ? ? ? ? ? ? ? ? ? } |Select-Object-PropertyImageName, ImageLabelImageName? ? ? ? ? ? ? ? ? ImageLabel-------------------captureTest-20160902-436096PS C:\windows\system32>Get-AzureVmImage|Where-Object{$_.DataDiskConfigurations-ne$null`>>-and($_.DataDiskConfigurations |Where-Object{$_.MediaLink-ne$null-and$_.MediaLink.Host.Contains($storageAccountName)}).Count-gt0`>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } |Select-Object-PropertyImageName, ImageLabelPS C:\windows\system32>Remove-AzureVMImage-ImageName"captureTest-20160902-436096"OperationDescription OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Remove-AzureVMImageb8f1c164-147a-4d98-9805-432dcd3b7105 Succeeded

#驗證存儲賬號是否符合遷移條件

PS C:\windows\system32> Move-AzureStorageAccount -Validate -StorageAccountName $storageAccountName

OperationId? ? ? ? : 68f3501e-f965-4732-aae5-a1da5b58103b

Result? ? ? ? ? ? : Validation Passed. Please see ValidationMessages object for a list of resources that will be migrated.

ValidationMessages : {<存儲賬號名稱>}

PS C:\windows\system32> $val=Move-AzureStorageAccount -Validate -StorageAccountName $storageAccountName

PS C:\windows\system32> $val.ValidationMessages

ResourceType? ? ? : Storage

ResourceName? ? ? : <存儲賬號名稱>

Category? ? ? ? ? : Information

Message? ? ? ? ? ? : Storage Account tcportalvhdsgrnnb3k173zr is eligible for migration.

VirtualMachineName :

#上述驗證通過后接下來執(zhí)行遷移準(zhǔn)備操作

PS C:\windows\system32> Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName

OperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus

--------------------? ? -----------? ? ? ? ? ? ? ? ? ? ? ? ? ---------------

Move-AzureStorageAccount 4086a517-a14a-4360-97aa-2714543dd345 Succeeded

#如果在遷移準(zhǔn)備操作中出現(xiàn)了報錯,或者您想取消本次遷移操作,可以使用下面命令進行取消

PS C:\windows\system32> Move-AzureStorageAccount -Abort -StorageAccountName $storageAccountName

OperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus

--------------------? ? -----------? ? ? ? ? ? ? ? ? ? ? ? ? ---------------

Move-AzureStorageAccount 8473i405-b3fg-7942-345h-8236hdy63i2f Succeeded

#如果遷移準(zhǔn)備步驟操作成功,那么可以執(zhí)行下述命令來生效遷移操作

PS C:\windows\system32> Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName

OperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus

--------------------? ? -----------? ? ? ? ? ? ? ? ? ? ? ? ? ---------------

Move-AzureStorageAccount cf4e80b3-8e26-4d65-96f2-98dda2266d49 Succeeded

```立即訪問http://market.azure.cn

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容