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

適用場(chǎng)景

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

Note

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

解決方案

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

PowerShell復(fù)制

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

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

復(fù)制

#您可以根據(jù)虛擬機(jī)所在的區(qū)域選擇 China North 或者 China EastPSC:\windows\system32>Get-AzureRmVMUsage -Location"China East"Name? ? ? ? ? ? ? ? ? ? ? ? ? ? CurrentValueLimitUnit----? ? ? ? ? ? ? ? ? ? ? ? ? ? ------------- -----? ----Availability Sets22000CountTotalRegional Cores39100CountVirtual Machines1710000CountVirtual MachineScaleSets12000CountStandard Dv2 Family Cores4100CountStandard FS Family Cores16100CountStandard A0-A7 Family Cores11100CountStandardDFamily Cores1100CountStandard Av2 Family Cores2100CountStandard DSv2 Family Cores4100CountStandard DS Family Cores1100CountBasic A Family Cores0100CountStandard A8-A11 Family Cores0100CountStandard G Family Cores0100CountStandard GS Family Cores0100CountStandard F Family Cores0100CountStandard NV Family Cores00CountStandard NC Family Cores00CountStandard H Family Cores00CountStandard LS Family Cores0100CountStandard Dv2 Promo Family Cores0100CountStandard DSv2 Promo Family Cores0100CountStandard MS Family Cores00CountStandard Dv3 Family Cores0100CountStandard DSv3 Family Cores0100CountStandard Ev3 Family Cores0100CountStandard ESv3 Family Cores0100CountStandard Storage Managed Disks010000CountPremium Storage Managed Disks010000Count

將同一個(gè) VNET 下的虛擬機(jī)從 ASM 遷移到 ARM 上

PowerShell復(fù)制

#將 ASM 下 VNET 的名稱(chēng)賦值給變量方便后面調(diào)用PS C:\windows\system32>$vnetName=""#驗(yàn)證 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...}#檢查驗(yàn)證中的告警信息PS C:\windows\system32>$validate=Move-AzureVirtualNetwork-Validate-VirtualNetworkName$vnetNamePS C:\windows\system32>$validate.ValidationMessagesResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱(chēng)>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱(chēng)>inDeployment <資源組名稱(chēng)> within Cloud Service <云服務(wù)名稱(chēng)> is eligibleformigration.VirtualMachineName : <虛擬機(jī)名稱(chēng)>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱(chēng)>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱(chēng)>inHostedService <云服務(wù)名稱(chēng)> 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 : <虛擬機(jī)名稱(chēng)>ResourceType? ? ? : VirtualNetworkResourceName? ? ? : Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Virtual Network is eligibleformigration.VirtualMachineName :ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱(chēng)>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Deployment <資源組名稱(chēng)>inCloud Service <云服務(wù)名稱(chēng)> is eligibleformigration.VirtualMachineName :ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱(chēng)>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱(chēng)>inDeployment <資源組名稱(chēng)> within Cloud Service <云服務(wù)名稱(chēng)> is eligibleformigration.VirtualMachineName : <虛擬機(jī)名稱(chēng)>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱(chēng)>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱(chēng)>inHostedService <云服務(wù)名稱(chēng)> 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 : <虛擬機(jī)名稱(chēng)>#上述驗(yàn)證通過(guò)后接下來(lái)執(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)了報(bào)錯(cuò),或者您想取消本次遷移操作,可以使用下面命令進(jìn)行取消

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

OperationDescription OperationId OperationStatus

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

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

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

OperationDescription OperationId OperationStatus

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

復(fù)制

遷移虛擬機(jī)所在的存儲(chǔ)賬號(hào)

PowerShell復(fù)制

#檢查存儲(chǔ)賬號(hào)下是否有未被遷移的虛擬機(jī)的 VHD 存在PS C:\windows\system32>$storageAccountName="<存儲(chǔ)賬號(hào)名稱(chēng)>"PS C:\windows\system32>Get-AzureDisk|where-Object{$_.MediaLink.Host.Contains($storageAccountName)} |Select-Object-ExpandPropertyAttachedTo-Property`>>? DiskName |Format-List-PropertyRoleName, DiskName#檢查存儲(chǔ)賬號(hào)下是否有已分離的虛擬機(jī)磁盤(pán),如有需要進(jìn)行刪除,如果您仍然需要這些磁盤(pán)可以將其復(fù)制到其他存儲(chǔ)賬號(hào)中PS C:\windows\system32>Get-AzureDisk|where-Object{$_.MediaLink.Host.Contains($storageAccountName)} |Where-Object-PropertyAttachedTo-EQ$null|Format-List-Property DiskNameDiskName : disktest#刪除磁盤(pán)PS C:\windows\system32>Remove-AzureDisk-DiskName"disktest"OperationDescription OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Remove-AzureDisk9661659d-3bcf-4e6e-bdc4-cce7c8d7a1e0 Succeeded#刪除存儲(chǔ)賬號(hào)中 OS 盤(pán)和數(shù)據(jù)盤(pán)中的虛擬機(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

復(fù)制

#驗(yàn)證存儲(chǔ)賬號(hào)是否符合遷移條件PS C:\windows\system32>Move-AzureStorageAccount-Validate-StorageAccountName$storageAccountNameOperationId? ? ? ? :68f3501e-f965-4732-aae5-a1da5b58103bResult? ? ? ? ? ? : Validation Passed. Please see ValidationMessages objectfora list of resources that will be migrated.ValidationMessages : {<存儲(chǔ)賬號(hào)名稱(chēng)>}PS C:\windows\system32>$val=Move-AzureStorageAccount-Validate-StorageAccountName$storageAccountNamePS C:\windows\system32>$val.ValidationMessagesResourceType? ? ? : StorageResourceName? ? ? : <存儲(chǔ)賬號(hào)名稱(chēng)>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Storage Account tcportalvhdsgrnnb3k173zr is eligibleformigration.VirtualMachineName :#上述驗(yàn)證通過(guò)后接下來(lái)執(zhí)行遷移準(zhǔn)備操作PS C:\windows\system32>Move-AzureStorageAccount-Prepare-StorageAccountName$storageAccountNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Move-AzureStorageAccount4086a517-a14a-4360-97aa-2714543dd345 Succeeded#如果在遷移準(zhǔn)備操作中出現(xiàn)了報(bào)錯(cuò),或者您想取消本次遷移操作,可以使用下面命令進(jìn)行取消PS C:\windows\system32>Move-AzureStorageAccount-Abort-StorageAccountName$storageAccountNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Move-AzureStorageAccount8473i405-b3fg-7942-345h-8236hdy63i2f Succeeded#如果遷移準(zhǔn)備步驟操作成功,那么可以執(zhí)行下述命令來(lái)生效遷移操作PS C:\windows\system32>Move-AzureStorageAccount-Commit-StorageAccountName$storageAccountNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Move-AzureStorageAccountcf4e80b3-8e26-4d65-96f2-98dda2266d49 Succeeded 立即訪(fǎng)問(wèn)http://market.azure.cn

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

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

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