使用 PowerShell 将 ExpressRoute 线路从经典部署模型转移到资源管理器部署模型Move ExpressRoute circuits from classic to Resource Manager deployment model using PowerShell

要将 ExpressRoute 线路同时用于经典部署模型和 Resource Manager 部署模型,必须将该线路移动到 Resource Manager 部署模型中。To use an ExpressRoute circuit for both the classic and Resource Manager deployment models, you must move the circuit to the Resource Manager deployment model. 以下部分可帮助使用 PowerShell 转移线路。The following sections help you move your circuit by using PowerShell.

准备阶段Before you begin

Note

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

移动 ExpressRoute 线路Move an ExpressRoute circuit

步骤 1:从经典部署模型收集线路详细信息Step 1: Gather circuit details from the classic deployment model

登录 Azure 经典环境并收集服务密钥。Sign in to the Azure classic environment and gather the service key.

  1. 登录到 Azure 帐户。Sign in to your Azure account.

    Add-AzureAccount
    
  2. 选择适当的 Azure 订阅。Select the appropriate Azure subscription.

    Select-AzureSubscription "<Enter Subscription Name here>"
    
  3. 为 Azure 和 ExpressRoute 导入 PowerShell 模块。Import the PowerShell modules for Azure and ExpressRoute.

    Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\Azure\Azure.psd1'
    Import-Module 'C:\Program Files\WindowsPowerShell\Modules\Azure\5.1.1\ExpressRoute\ExpressRoute.psd1'
    
  4. 使用下面的 cmdlet 获取所有 ExpressRoute 线路的服务密钥。Use the cmdlet below to get the service keys for all of your ExpressRoute circuits. 检索密钥后,请复制要移动到 Resource Manager 部署模型的线路的 服务密钥After retrieving the keys, copy the service key of the circuit that you want to move to the Resource Manager deployment model.

    Get-AzureDedicatedCircuit
    

步骤 2:登录并创建资源组Step 2: Sign in and create a resource group

登录 Resource Manager 环境并创建新的资源组。Sign in to the Resource Manager environment and create a new resource group.

  1. 登录 Azure Resource Manager 环境。Sign in to your Azure Resource Manager environment.

    Connect-AzAccount -Environment AzureChinaCloud
    
  2. 选择相应的 Azure 订阅。Select the appropriate Azure subscription.

    Get-AzSubscription -SubscriptionName "<Enter Subscription Name here>" | Select-AzSubscription
    
  3. 如果还没有资源组,请修改下面的片段,创建新的资源组。Modify the snippet below to create a new resource group if you don't already have a resource group.

    New-AzResourceGroup -Name "DemoRG" -Location "China East"
    

步骤 3:将 ExpressRoute 线路转移到 Resource Manager 部署模型Step 3: Move the ExpressRoute circuit to the Resource Manager deployment model

现在,可以将 ExpressRoute 线路从经典部署模型移动到 Resource Manager 部署模型。You are now ready to move your ExpressRoute circuit from the classic deployment model to the Resource Manager deployment model. 在继续下之前,请先查看将 ExpressRoute 线路从经典部署模型移动到 Resource Manager 部署模型中提供的信息。Before proceeding, review the information provided in Moving an ExpressRoute circuit from the classic to the Resource Manager deployment model.

若要移动线路,请修改并运行以下代码片段:To move your circuit, modify and run the following snippet:

Move-AzExpressRouteCircuit -Name "MyCircuit" -ResourceGroupName "DemoRG" -Location "China East" -ServiceKey "<Service-key>"

在经典模式下,ExpressRoute 线路没有绑定到区域的概念。In classic mode, an ExpressRoute circuit does not have the concept of being tied to a region. 但是,在资源管理器中,每个资源都需要映射到 Azure 区域。However, in Resource Manager, every resource needs to be mapped to an Azure region. 从技术上来讲,Move-AzExpressRouteCircuit cmdlet 中指定的区域可以是任何区域。The region specified in the Move-AzExpressRouteCircuit cmdlet can technically be any region. 对组织来说,建议选择一个最能代表对等位置的区域。For organizational purposes, you may want to choose a region that closely represents your peering location.

Note

转移完成之后,列在前一个 cmdlet 中的新名称用于处理资源。After the move has finished, the new name that is listed in the previous cmdlet will be used to address the resource. 线路实质上已重命名。The circuit will essentially be renamed.

修改线路访问Modify circuit access

为两种部署模型启用 ExpressRoute 线路访问To enable ExpressRoute circuit access for both deployment models

将经典 ExpressRoute 线路移动到 Resource Manager 部署模型后,可以启用对两种部署模型的访问。After moving your classic ExpressRoute circuit to the Resource Manager deployment model, you can enable access to both deployment models. 运行以下 cmdlet 启用对两种部署模型的访问:Run the following cmdlets to enable access to both deployment models:

  1. 获取线路详细信息。Get the circuit details.

    $ckt = Get-AzExpressRouteCircuit -Name "DemoCkt" -ResourceGroupName "DemoRG"
    
  2. 将“允许经典操作”设置为“TRUE”。Set "Allow Classic Operations" to TRUE.

    $ckt.AllowClassicOperations = $true
    
  3. 更新线路。Update the circuit. 成功完成此操作后,可以在经典部署模型中查看线路。After this operation has finished successfully, you will be able to view the circuit in the classic deployment model.

    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt
    
  4. 运行以下 cmdlet 获取 ExpressRoute 线路的详细信息。Run the following cmdlet to get the details of the ExpressRoute circuit. 服务密钥必须已列出。You must be able to see the service key listed.

    get-azurededicatedcircuit
    
  5. 现在,可以使用经典 VNet 的经典部署模型命令以及 Resource Manager VNet 的 Resource Manager 命令来管理 ExpressRoute 线路的链接。You can now manage links to the ExpressRoute circuit using the classic deployment model commands for classic VNets, and the Resource Manager commands for Resource Manager VNets. 以下文章可帮助管理 ExpressRoute 线路的链接:The following articles help you manage links to the ExpressRoute circuit:

禁用对经典部署模型的 ExpressRoute 线路访问To disable ExpressRoute circuit access to the classic deployment model

运行以下 cmdlet 可禁止访问经典部署模型。Run the following cmdlets to disable access to the classic deployment model.

  1. 获取 ExpressRoute 线路的详细信息。Get details of the ExpressRoute circuit.

    $ckt = Get-AzExpressRouteCircuit -Name "DemoCkt" -ResourceGroupName "DemoRG"
    
  2. 将“允许经典操作”设置为“FALSE”。Set "Allow Classic Operations" to FALSE.

    $ckt.AllowClassicOperations = $false
    
  3. 更新线路。Update the circuit. 成功完成此操作后,你无法在经典部署模型中查看线路。After this operation has finished successfully, you will not be able to view the circuit in the classic deployment model.

    Set-AzExpressRouteCircuit -ExpressRouteCircuit $ckt
    

后续步骤Next steps