適用場景
用戶擁有多個云服務(wù)但是在同一個 VNET 下,希望將這些虛擬機(jī)從經(jīng)典部署模型(以下簡稱:ASM)遷移到 Azure Resource Manager(以下簡稱:ARM)。
Note
如果您未使用 VNET解滓,希望將同一個云服務(wù)下的虛擬機(jī)從 ASM 模式遷移到 ARM 模式躲因,您可以參考這篇文章:如何將同一個云服務(wù)下的虛擬機(jī)從 ASM 遷移到 ARM 上
解決方案
首先,我們登陸到需要遷移的虛擬機(jī)所在的訂閱下,注冊遷移服務(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? ? ? : <訂閱名稱>CurrentStorageAccount :#如果您需要遷移某個特定訂閱下的虛擬機(jī)硼一,需要手動進(jìn)行指定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)典模式中需要遷移的虛擬機(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 }#如果您需要遷移某個特定訂閱下的虛擬機(jī)似谁,需要手動進(jìn)行指定Select-AzureSubscription–SubscriptionName"<訂閱名稱>"
檢查 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
將同一個 VNET 下的虛擬機(jī)從 ASM 遷移到 ARM 上
PowerShell復(fù)制
#將 ASM 下 VNET 的名稱賦值給變量方便后面調(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? ? ? : <資源組名稱>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱>inDeployment <資源組名稱> within Cloud Service <云服務(wù)名稱> is eligibleformigration.VirtualMachineName : <虛擬機(jī)名稱>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱>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 : <虛擬機(jī)名稱>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 <虛擬機(jī)名稱>inDeployment <資源組名稱> within Cloud Service <云服務(wù)名稱> is eligibleformigration.VirtualMachineName : <虛擬機(jī)名稱>ResourceType? ? ? : DeploymentResourceName? ? ? : <資源組名稱>Category? ? ? ? ? : WarningMessage? ? ? ? ? ? : VM <虛擬機(jī)名稱>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 : <虛擬機(jī)名稱>#上述驗(yàn)證通過后接下來執(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)了報錯掠哥,或者您想取消本次遷移操作,可以使用下面命令進(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í)行下述命令來生效遷移操作
PS C:\windows\system32> Move-AzureVirtualNetwork -Commit -VirtualNetworkName $vnetName
OperationDescription OperationId OperationStatus
Move-AzureVirtualNetwork 1ce54778-bbcf-403d-b971-a13993484212 Succeeded
復(fù)制
遷移虛擬機(jī)所在的存儲賬號
PowerShell復(fù)制
#檢查存儲賬號下是否有未被遷移的虛擬機(jī)的 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#檢查存儲賬號下是否有已分離的虛擬機(jī)磁盤续搀,如有需要進(jìn)行刪除,如果您仍然需要這些磁盤可以將其復(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ù)盤中的虛擬機(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)證存儲賬號是否符合遷移條件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 : {<存儲賬號名稱>}PS C:\windows\system32>$val=Move-AzureStorageAccount-Validate-StorageAccountName$storageAccountNamePS C:\windows\system32>$val.ValidationMessagesResourceType? ? ? : StorageResourceName? ? ? : <存儲賬號名稱>Category? ? ? ? ? : InformationMessage? ? ? ? ? ? : Storage Account tcportalvhdsgrnnb3k173zr is eligibleformigration.VirtualMachineName :#上述驗(yàn)證通過后接下來執(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)了報錯菠净,或者您想取消本次遷移操作禁舷,可以使用下面命令進(jìn)行取消PS C:\windows\system32>Move-AzureStorageAccount-Abort-StorageAccountName$storageAccountNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Move-AzureStorageAccount8473i405-b3fg-7942-345h-8236hdy63i2f Succeeded#如果遷移準(zhǔn)備步驟操作成功,那么可以執(zhí)行下述命令來生效遷移操作PS C:\windows\system32>Move-AzureStorageAccount-Commit-StorageAccountName$storageAccountNameOperationDescription? ? OperationId? ? ? ? ? ? ? ? ? ? ? ? ? OperationStatus----------------------------------------------Move-AzureStorageAccountcf4e80b3-8e26-4d65-96f2-98dda2266d49 Succeeded 立即訪問http://market.azure.cn