适用场景

用户希望将特定云服务下的所有虚拟机从经典部署模型(以下简称:ASM)迁移到 Azure Resource Manager(以下简称:ARM)。

Note

如果云服务下使用 VNET 也希望将虚拟机从 ASM 模式迁移到 ARM 模式,您可以参考这篇文章:如何将同一个 VNET 下的虚拟机从 ASM 迁移到 ARM 上

解决方案

首先,我们登陆到需要迁移的虚拟机所在的订阅下,注册迁移服务:

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"<订阅名称>"#注册迁移服务PS C:\windows\system32>Register-AzureRmResourceProvider-ProviderNamespaceMicrosoft.ClassicInfrastructureMigrate#迁移服务注册一般需要 5 分钟左右,您可以通过下述命令查看完成情况,PS C:\windows\system32>Get-AzureRmResourceProvider-ProviderNamespaceMicrosoft.ClassicInfrastructureMigrateProviderNamespace : Microsoft.ClassicInfrastructureMigrateRegistrationState : RegisteredResourceTypes    : {classicInfrastructureResources}Locations        : {China North, China East}#最后登陆到经典模式中需要迁移的虚拟机所在订阅下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"<订阅名称>"

Note

注册迁移服务为一次性操作,注册完成后以后迁移时无需再次注册,但是如果您在未注册前尝试迁移,会收到报错说该订阅未注册迁移服务。

检查 ARM 模式下您订阅里的配额,确保需要迁移的虚拟机有足够的配额可以使用:

PowerShell复制

#您可以根据虚拟机所在的区域选择 China North 或者 China EastPS C:\windows\system32>Get-AzureRmVMUsage-Location"China East"Name                            Current Value Limit  Unit--------------------------Availability Sets22000CountTotal Regional Cores39100CountVirtual Machines1710000CountVirtual Machine Scale Sets12000CountStandard Dv2 Family Cores4100CountStandard FS Family Cores16100CountStandard A0-A7 Family Cores11100CountStandard D Family 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

将同一个云服务下的虚拟机从 ASM 迁移到 ARM 上:

PowerShell复制

#查询云服务并找出您想要迁移的云服务,此处以 1vnet2cs02 为例PS C:\windows\system32>Get-AzureService|ft ServicenameServiceName-----------1vent2cs041vnet2cs011vnet2cs021vnet2cs03#获取部署名称PS C:\windows\system32>$serviceName="1vnet2cs02"PS C:\windows\system32>$deployment=Get-AzureDeployment-ServiceName$serviceNamePS C:\windows\system32>$deploymentName=$deployment.DeploymentNameResult            : 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...}

选择 1:将 VM 迁移到一个新建的虚拟网络中:

PowerShell复制

#验证云服务PS C:\windows\system32>Move-AzureService-Validate-ServiceName$serviceName` -DeploymentName$deploymentName-CreateNewVirtualNetworkOperationId        :119a8709-4160-4122-859d-a1bc2dc8c603Result            : Validation Passed. Please see ValidationMessages objectfora list of resources that will be migrated.ValidationMessages : {cs03, cs03, cs03}#上述验证通过后接下来执行迁移准备操作PS C:\windows\system32>Move-AzureService-Prepare-ServiceName$serviceName`>>-DeploymentName$deploymentName-CreateNewVirtualNetworkOperationDescription OperationId                          OperationStatus----------------------------------------------Move-AzureService7a6931ef-6f42-47dc-8d99-0929fbdc5658 Succeeded#如果迁移准备步骤操作成功,那么可以执行下述命令来生效迁移操作PS C:\windows\system32>Move-AzureService-Commit-ServiceName$serviceName-DeploymentName$deploymentNameOperationDescription OperationId                          OperationStatus----------------------------------------------Move-AzureServicee88c11c0-21d4-46c0-abb0-700c324b21ba Succeeded

选择 2:将 VM 迁移到一个已有的虚拟网络中:

PowerShell复制

#准备已有虚拟网络的相关信息PS C:\windows\system32>$existingVnetRGName="<虚拟网络所在的资源组名称>"PS C:\windows\system32>$vnetName="<虚拟网络名称>"PS C:\windows\system32>$subnetName="<子网名称>"#验证云服务PS C:\windows\system32>Move-AzureService-Validate-ServiceName$serviceName`>>-DeploymentName$deploymentName-UseExistingVirtualNetwork-VirtualNetworkResourceGroupName$existingVnetRGName-VirtualNetworkName$vnetName-SubnetName$subnetName#上述验证通过后接下来执行迁移准备操作PS C:\windows\system32>Move-AzureService-Prepare-ServiceName$serviceName-DeploymentName$deploymentName`>>-UseExistingVirtualNetwork-VirtualNetworkResourceGroupName$existingVnetRGName`>>-VirtualNetworkName$vnetName-SubnetName$subnetNameOperationDescription OperationId                          OperationStatus----------------------------------------------Move-AzureService9c9e01a6-183e-4884-b51d-04f25112934e Succeeded#如果迁移准备步骤操作成功,那么可以执行下述命令来生效迁移操作PS C:\windows\system32>Move-AzureService-Commit-ServiceName$serviceName-DeploymentName$deploymentNameOperationDescription OperationId                          OperationStatus----------------------------------------------Move-AzureServicec803cc0d-1446-4922-bcb1-af1330828c69 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#检查存储账号下是否有已分离的虚拟机磁盘,如有需要进行删除,如果您仍然需要这些磁盘可以将其复制到其他存储账号中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 盘和数据盘中的虚拟机镜像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 :

#上述验证通过后接下来执行迁移准备操作

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

OperationDescription    OperationId                          OperationStatus

--------------------    -----------                          ---------------

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

#如果在迁移准备操作中出现了报错,或者您想取消本次迁移操作,可以使用下面命令进行取消

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

OperationDescription    OperationId                          OperationStatus

--------------------    -----------                          ---------------

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

#如果迁移准备步骤操作成功,那么可以执行下述命令来生效迁移操作

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

OperationDescription    OperationId                          OperationStatus

--------------------    -----------                          ---------------

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

```立即访问http://market.azure.cn

如何将同一云服务下的虚拟机从经典部署模型迁移到 Azure Resource Manager的更多相关文章

  1. 如何将同一 VNET 下的虚拟机从经典部署模型迁移到 Azure Resource Manager

    本文内容 适用场景 解决方案 适用场景 用户拥有多个云服务但是在同一个 VNET 下,希望将这些虚拟机从经典部署模型(以下简称:ASM)迁移到 Azure Resource Manager(以下简称: ...

  2. 为 Azure Resource Manager 中的虚拟机设置 WinRM 访问权限

    Azure 服务管理中的 WinRM 与 Azure Resource Manager Note Azure 具有用于创建和处理资源的两个不同的部署模型:Resource Manager 和经典. 本 ...

  3. 连接到 Azure 上的 SQL Server 虚拟机(经典部署)

    概述 本主题介绍如何连接到运行于 Azure 虚拟机的 SQL Server 实例. 它介绍了一些常规连接方案,并提供了在 Azure VM 中配置 SQL Server 连接的详细步骤. Impor ...

  4. 在 Azure Resource Manager 中为虚拟机设置密钥保管库

    Note Azure 具有两种不同的部署模型,用于创建和处理资源:Resource Manager 模型和经典模型.本文介绍使用 Resource Manager 部署模型.Azure 建议对大多数新 ...

  5. 【Azure云服务 Cloud Service】如何在部署云服务Cloud Service时候通过启动任务Start Task来配置IIS (如开启ARR)

    问题情形 通过VS部署Cloud Service时,需要在开始任务时候安装或配置其他任务,如安装及配置ARR. 执行步骤 1) 下载 requestRouter_amd64.msi 和 webfarm ...

  6. Windows Azure中WebSite 网站, Cloud Service 云服务,Virtual Machine 虚拟机的比较

    在Windows Azure服务平台里,Web Site特点是: 在Windows Azure上构建高度可扩展的Web站点. 快速.轻松部署一个高度可扩展的云环境,并且可以从很小的规模开始. 使用您所 ...

  7. Windows Azure -Azure 网站、云服务和虚拟机的对比

    Azure 网站.云服务和虚拟机对比 概述 Azure提供了几种方法来承载网站: Azure网站.云服务和虚拟机.本文帮助您了解选项和为您的Web应用程序做出正确选择. Azure网站是大多数web应 ...

  8. 面向阿里云专家的 Azure 云服务介绍

    本文是面向阿里云专家的 Azure 云服务介绍,参考本文可以帮助大家“按图索骥”在 Azure 的平台上找到能满足自己需求的服务. 在公有云计算蓬勃发展的同时,中国也出现了越来越多的本土公有云平台.针 ...

  9. [转]在 Azure 云服务上设计大规模服务的最佳实践

    本文转自:http://technet.microsoft.com/zh-cn/magazine/jj717232.aspx 英文版:http://msdn.microsoft.com/library ...

随机推荐

  1. .net 中 C# 简单自定义事件实现

    个人认为事件处理机制是一种很好的机制 特别是可以方便安全的实现窗口间(子窗口对父窗口,子窗口间等)的消息传递.功能调用 下面展现的源自以前论坛上看到的一套方法,可能记得不大准确,所以可能不规范,我的理 ...

  2. (转)Mybatis MapperScannerConfigurer 自动扫描 将Mapper接口生成代理注入到Spring

    Mybatis MapperScannerConfigurer 自动扫描 将Mapper接口生成代理注入到Spring Mybatis在与Spring集成的时候可以配置MapperFactoryBea ...

  3. linq中last或者lastordefault不存在的问题

    在使用linq访问数据库的时候发现first以及firstordefault都存在,但是last以及lastordefault不存在.上网找寻一番发现是last只在linq to object中实现了 ...

  4. rails中accepts_nested_attributes_for应用

    Model: class Blog < ActiveRecord::Base has_many :strip_rules accepts_nested_attributes_for :strip ...

  5. 比較C struct 與 C# unsafe struct内存分佈

    昨晚在群裏無意間看到一個朋友有一個需求.他是在C裏面將兩個結構體(HeadStruct,BodyStruct)的内存數據直接通過socket send發給C#寫的服務端來處理.當然他之前所使用的需求基 ...

  6. OAuth 2.0授权之授权码授权

    OAuth 2.0 是一个开放的标准协议,允许应用程序访问其它应用的用户授权的数据(如用户名.头像.昵称等).比如使用微信.QQ.支付宝登录等第三方网站,只需要用户点击授权按钮,第三方网站就会获取到用 ...

  7. ffplay源码分析3-代码框架

    ffplay是FFmpeg工程自带的简单播放器,使用FFmpeg提供的解码器和SDL库进行视频播放.本文基于FFmpeg工程4.1版本进行分析,其中ffplay源码清单如下: https://gith ...

  8. MySQL5.7+版本一些问题

    今天有一个需求.我要用本地的Java调用远程服务器的MySQL,因为我的MySQL版本为5.7.2,即比较新的版本.网上找的很多都比较旧,故贴此贴. 无密码: 初次安装MySQL可能没有设置密码,网上 ...

  9. sscanf函数详解 & 查找文件字符串

    1. sscanf函数 sscanf() - 从一个字符串中读进与指定格式相符的数据. 1.1 函数原型 int scanf(const char *format, ...); int fscanf( ...

  10. 【angular5项目积累总结】文件上传

    <div class="form-group row"> <label class="col-sm-2 col-form-label"> ...