使用 CLI 创建和修改 ExpressRoute 线路Create and modify an ExpressRoute circuit using CLI

本文介绍如何使用命令行接口 (CLI) 创建 Azure ExpressRoute 线路。This article describes how to create an Azure ExpressRoute circuit by using the Command Line Interface (CLI). 本文还介绍如何检查状态,以及如何更新、删除和取消预配线路。This article also shows you how to check the status, update, or delete and deprovision a circuit. 如果想使用不同的方法处理 ExpressRoute 线路,请从以下列表中选择一篇文章进行参阅:If you want to use a different method to work with ExpressRoute circuits, you can select the article from the following list:

准备阶段Before you begin

创建和预配 ExpressRoute 线路Create and provision an ExpressRoute circuit

1.登录到 Azure 帐户,然后选择订阅1. Sign in to your Azure account and select your subscription

要开始配置,请登录到 Azure 帐户。To begin your configuration, sign in to your Azure account. 使用以下示例来帮助连接:Use the following examples to help you connect:

az login

检查该帐户的订阅。Check the subscriptions for the account.

az account list

选择要为其创建 ExpressRoute 线路的订阅。Select the subscription for which you want to create an ExpressRoute circuit.

az account set --subscription "<subscription ID>"

2.获取支持的提供商、位置和带宽的列表2. Get the list of supported providers, locations, and bandwidths

在创建 ExpressRoute 线路之前,需要支持的连接服务提供商、位置和带宽选项的列表。Before you create an ExpressRoute circuit, you need the list of supported connectivity providers, locations, and bandwidth options. CLI 命令“az network express-route list-service-providers”会返回此信息,在随后的步骤中将使用此信息:The CLI command 'az network express-route list-service-providers' returns this information, which you’ll use in later steps:

az network express-route list-service-providers

其响应类似于如下示例:The response is similar to the following example:

[
  {
    "bandwidthsOffered": [
      {
        "offerName": "50Mbps",
        "valueInMbps": 50
      },
      {
        "offerName": "100Mbps",
        "valueInMbps": 100
      },
      {
        "offerName": "200Mbps",
        "valueInMbps": 200
      },
      {
        "offerName": "500Mbps",
        "valueInMbps": 500
      },
      {
        "offerName": "1Gbps",
        "valueInMbps": 1000
      },
      {
        "offerName": "2Gbps",
        "valueInMbps": 2000
      },
      {
        "offerName": "5Gbps",
        "valueInMbps": 5000
      },
      {
        "offerName": "10Gbps",
        "valueInMbps": 10000
      }
    ],
    "id": "/subscriptions//resourceGroups//providers/Microsoft.Network/expressRouteServiceProviders/",
    "location": null,
    "name": "Beijing Telecom Ethernet",
    "peeringLocations": [
      "Beijing"
    ],
    "provisioningState": "Succeeded",
    "resourceGroup": "",
    "tags": null,
    "type": "Microsoft.Network/expressRouteServiceProviders"
  },
  {
    "bandwidthsOffered": [
      {
        "offerName": "50Mbps",
        "valueInMbps": 50
      },
      {
        "offerName": "100Mbps",
        "valueInMbps": 100
      },
      {
        "offerName": "200Mbps",
        "valueInMbps": 200
      },
      {
        "offerName": "500Mbps",
        "valueInMbps": 500
      },
      {
        "offerName": "1Gbps",
        "valueInMbps": 1000
      },
      {
        "offerName": "2Gbps",
        "valueInMbps": 2000
      },
      {
        "offerName": "5Gbps",
        "valueInMbps": 5000
      },
      {
        "offerName": "10Gbps",
        "valueInMbps": 10000
      }
    ],
    "id": "/subscriptions//resourceGroups//providers/Microsoft.Network/expressRouteServiceProviders/",
    "location": null,
    "name": "Shanghai Telecom Ethernet",
    "peeringLocations": [
      "Shanghai"
    ],
    "provisioningState": "Succeeded",
    "resourceGroup": "",
    "tags": null,
    "type": "Microsoft.Network/expressRouteServiceProviders"
  }
]

查看此响应以检查你的连接服务提供商是否已在此处列出。Check the response to see if your connectivity provider is listed. 请记下以下信息,稍后在创建线路时需要用到:Make a note of the following information, which you will need when you create a circuit:

  • NameName
  • PeeringLocationsPeeringLocations
  • BandwidthsOfferedBandwidthsOffered

现在,已经准备创建 ExpressRoute 线路。You're now ready to create an ExpressRoute circuit.

3.创建 ExpressRoute 线路3. Create an ExpressRoute circuit

Important

从发布服务密钥的那一刻起,将对 ExpressRoute 线路进行计费。Your ExpressRoute circuit is billed from the moment a service key is issued. 在连接服务提供商准备好预配线路后,请执行此操作。Perform this operation when the connectivity provider is ready to provision the circuit.

如果尚未有资源组,则在创建 ExpressRoute 线路之前,必须先创建一个资源组。If you don't already have a resource group, you must create one before you create your ExpressRoute circuit. 可以运行以下命令来创建资源组:You can create a resource group by running the following command:

az group create -n ExpressRouteResourceGroup -l "China North"

以下示例演示如何通过位于北京的 Beijing Telecom Ethernet 创建 200-Mbps 的 ExpressRoute 线路。The following example shows how to create a 200-Mbps ExpressRoute circuit through Beijing Telecom Ethernet in Beijing. 如果使用其他提供商和其他设置,请在发出请求时替换该信息。If you're using a different provider and different settings, substitute that information when you make your request.

请确保指定合适的 SKU 层和 SKU 系列:Make sure that you specify the correct SKU tier and SKU family:

  • SKU 层决定是否启用 ExpressRoute 标准版或 ExpressRoute 高级版外接程序。SKU tier determines whether an ExpressRoute standard or an ExpressRoute premium add-on is enabled. 可以指定“Standard”以获取标准 SKU,或指定“Premium”以获取高级版外接程序。You can specify 'Standard' to get the standard SKU or 'Premium' for the premium add-on.
  • SKU 系列确定计费类型。SKU family determines the billing type. 可以指定“Metereddata”以获取数据流量套餐,指定“Unlimiteddata”以获取无限制流量套餐。You can specify 'Metereddata' for a metered data plan and 'Unlimiteddata' for an unlimited data plan. 可将计费类型从“Metereddata”更改为“Unlimiteddata”,但不能将类型从“Unlimiteddata”更改为“Metereddata”。You can change the billing type from 'Metereddata' to 'Unlimiteddata', but you can't change the type from 'Unlimiteddata' to 'Metereddata'.

从发布服务密钥的那一刻起,会对 ExpressRoute 线路进行计费。Your ExpressRoute circuit is billed from the moment a service key is issued. 以下是请求新的服务密钥的示例:The following example is a request for a new service key:

az network express-route create --bandwidth 200 -n MyCircuit --peering-location "Beijing" -g ExpressRouteResourceGroup --provider "Beijing Telecom Ethernet" -l "China North" --sku-family MeteredData --sku-tier Standard

响应包含服务密钥。The response contains the service key.

4.列出所有 ExpressRoute 线路4. List all ExpressRoute circuits

要获取已创建的所有 ExpressRoute 线路的列表,请运行 az network express-route list 命令。To get a list of all the ExpressRoute circuits that you created, run the az network express-route list command. 可以随时使用此命令检索此信息。You can retrieve this information at any time by using this command. 若要列出所有线路,请进行不带任何参数的调用。To list all circuits, make the call with no parameters.

az network express-route list

服务密钥会在响应的 ServiceKey 字段中列出。Your service key is listed in the ServiceKey field of the response.

"allowClassicOperations": false,
"authorizations": [],
"circuitProvisioningState": "Enabled",
"etag": "W/\"1262c492-ffef-4a63-95a8-a6002736b8c4\"",
"gatewayManagerEtag": null,
"id": "/subscriptions/81ab786c-56eb-4a4d-bb5f-f60329772466/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/MyCircuit",
"location": "chinanorth",
"name": "MyCircuit",
"peerings": [],
"provisioningState": "Succeeded",
"resourceGroup": "ExpressRouteResourceGroup",
"serviceKey": "1d05cf70-1db5-419f-ad86-1ca62c3c125b",
"serviceProviderNotes": null,
"serviceProviderProperties": {
  "bandwidthInMbps": 200,
  "peeringLocation": "Beijing",
  "serviceProviderName": "Beijing Telecom Ethernet"
},
"serviceProviderProvisioningState": "NotProvisioned",
"sku": {
  "family": "UnlimitedData",
  "name": "Standard_MeteredData",
  "tier": "Standard"
},
"tags": null,
"type": "Microsoft.Network/expressRouteCircuits]

可以通过使用“-h”参数运行以下命令获取所有参数的详细说明。You can get detailed descriptions of all the parameters by running the command using the '-h' parameter.

az network express-route list -h

5.将服务密钥发送给连接服务提供商进行预配5. Send the service key to your connectivity provider for provisioning

“ServiceProviderProvisioningState”提供有关服务提供商端当前预配状态的信息。'ServiceProviderProvisioningState' provides information about the current state of provisioning on the service-provider side. 此状态提供 Microsoft 端的状态。The status provides the state on the Microsoft side. 有关详细信息,请参阅工作流文章For more information, see the Workflows article.

创建新的 ExpressRoute 线路时,线路处于以下状态:When you create a new ExpressRoute circuit, the circuit is in the following state:

"serviceProviderProvisioningState": "NotProvisioned"
"circuitProvisioningState": "Enabled"

当连接服务提供商正在为你启用线路时,线路将更改为以下状态:The circuit changes to the following state when the connectivity provider is in the process of enabling it for you:

"serviceProviderProvisioningState": "Provisioning"
"circuitProvisioningState": "Enabled"

只有 ExpressRoute 线路处于以下状态时,才能使用它。For you to be able to use an ExpressRoute circuit, it must be in the following state:

"serviceProviderProvisioningState": "Provisioned"
"circuitProvisioningState": "Enabled

6.定期检查线路密钥的状态6. Periodically check the status and the state of the circuit key

检查线路密钥的状态,可以通过此状态了解提供商何时启用了线路。Checking the status and the state of the circuit key lets you know when your provider has enabled your circuit. 配置线路后,“ServiceProviderProvisioningState” 会显示为“Provisioned”,如以下示例所示:After the circuit has been configured, 'ServiceProviderProvisioningState' appears as 'Provisioned', as shown in the following example:

az network express-route show --resource-group ExpressRouteResourceGroup --name MyCircuit

其响应类似于如下示例:The response is similar to the following example:

"allowClassicOperations": false,
"authorizations": [],
"circuitProvisioningState": "Enabled",
"etag": "W/\"1262c492-ffef-4a63-95a8-a6002736b8c4\"",
"gatewayManagerEtag": null,
"id": "/subscriptions/81ab786c-56eb-4a4d-bb5f-f60329772466/resourceGroups/ExpressRouteResourceGroup/providers/Microsoft.Network/expressRouteCircuits/MyCircuit",
"location": "chinanorth",
"name": "MyCircuit",
"peerings": [],
"provisioningState": "Succeeded",
"resourceGroup": "ExpressRouteResourceGroup",
"serviceKey": "1d05cf70-1db5-419f-ad86-1ca62c3c125b",
"serviceProviderNotes": null,
"serviceProviderProperties": {
  "bandwidthInMbps": 200,
  "peeringLocation": "Beijing",
  "serviceProviderName": "Beijing Telecom Ethernet"
},
"serviceProviderProvisioningState": "NotProvisioned",
"sku": {
  "family": "UnlimitedData",
  "name": "Standard_MeteredData",
  "tier": "Standard"
},
"tags": null,
"type": "Microsoft.Network/expressRouteCircuits]

7.创建路由配置7. Create your routing configuration

有关分步说明,请参阅 ExpressRoute 线路路由配置一文,了解如何创建和修改线路对等互连。For step-by-step instructions, see the ExpressRoute circuit routing configuration article to create and modify circuit peerings.

Important

这些说明仅适用于由提供第 2 层连接服务的服务提供商创建的线路。These instructions only apply to circuits that are created with service providers that offer layer 2 connectivity services. 如果服务提供商提供第 3 层托管服务(通常是 IP VPN,如 MPLS),则连接服务提供商会配置和管理路由。If you're using a service provider that offers managed layer 3 services (typically an IP VPN, like MPLS), your connectivity provider configures and manages routing for you.

接下来,将虚拟网络链接到 ExpressRoute 线路。Next, link a virtual network to your ExpressRoute circuit. 按照将虚拟网络链接到 ExpressRoute 线路文章中的内容进行操作。Use the Linking virtual networks to ExpressRoute circuits article.

修改 ExpressRoute 线路Modifying an ExpressRoute circuit

可以在不影响连接的情况下修改 ExpressRoute 线路的某些属性。You can modify certain properties of an ExpressRoute circuit without impacting connectivity. 可以在不停机的情况下进行以下更改:You can make the following changes with no downtime:

  • 为 ExpressRoute 线路启用或禁用 ExpressRoute 高级版外接程序。You can enable or disable an ExpressRoute premium add-on for your ExpressRoute circuit.
  • 增加 ExpressRoute 线路的带宽,前提是端口上有可用容量。You can increase the bandwidth of your ExpressRoute circuit provided there is capacity available on the port. 但不支持对线路的带宽进行降级。However, downgrading the bandwidth of a circuit is not supported.
  • 将计量套餐从数据流量套餐更改为无限制流量套餐。You can change the metering plan from Metered Data to Unlimited Data. 但不支持将计量套餐从无限制流量套餐更改为数据流量套餐。However, changing the metering plan from Unlimited Data to Metered Data is not supported.
  • 可以启用和禁用允许经典操作 。You can enable and disable Allow Classic Operations.

有关限制和局限性的详细信息,请参阅 ExpressRoute 常见问题解答For more information on limits and limitations, see the ExpressRoute FAQ.

启用 ExpressRoute 高级版外接程序To enable the ExpressRoute premium add-on

可以使用以下命令为现有线路启用 ExpressRoute 高级版外接程序:You can enable the ExpressRoute premium add-on for your existing circuit by using the following command:

az network express-route update -n MyCircuit -g ExpressRouteResourceGroup --sku-tier Premium

线路现已启用 ExpressRoute 高级版外接程序功能。The circuit now has the ExpressRoute premium add-on features enabled. 该命令成功运行后,我们就会开始对高级版外接程序功能进行计费。We begin billing you for the premium add-on capability as soon as the command has successfully run.

禁用 ExpressRoute 高级版外接程序To disable the ExpressRoute premium add-on

Important

如果使用的资源超出标准线路允许的范围,此操作可能会失败。This operation can fail if you're using resources that are greater than what is permitted for the standard circuit.

在禁用 ExpressRoute 高级版外接程序之前,请了解以下条件:Before disabling the ExpressRoute premium add-on, understand the following criteria:

  • 从高级版降级到标准版之前,必须确保链接到线路的虚拟网络数量少于 10。Before you downgrade from premium to standard, you must make sure that you have fewer than 10 virtual networks linked to the circuit. 如果超过 10 个,更新请求则会失败,并且我们将按高级版费率进行收费。If you have more than 10, your update request fails, and we bill you at premium rates.
  • 必须取消其他地理政治区域的所有虚拟网络的链接。You must unlink all virtual networks in other geopolitical regions. 如果没有对所有虚拟网络取消链接,更新请求则会失败,并且我们将按高级版费率进行收费。If you don't unlink all your virtual networks, your update request fails and we bill you at premium rates.
  • 路由表中专用对等互连的路由必须少于 4,000。Your route table must be less than 4,000 routes for private peering. 如果你的路由表大小大于 4,000 路由,BGP 会话则会掉线。If your route table size is greater than 4,000 routes, the BGP session drops. 在播发的前缀数量小于 4,000 之前,不会重新启用此会话。The session won't be reenabled until the number of advertised prefixes is below 4,000.

可以使用以下示例为现有线路禁用 ExpressRoute 高级版外接程序:You can disable the ExpressRoute premium add-on for the existing circuit by using the following example:

az network express-route update -n MyCircuit -g ExpressRouteResourceGroup --sku-tier Standard

更新 ExpressRoute 线路带宽To update the ExpressRoute circuit bandwidth

有关提供商支持的带宽选项,请查看 ExpressRoute 常见问题解答For the supported bandwidth options for your provider, check the ExpressRoute FAQ. 可以选取大于现有线路大小的任何大小。You can pick any size greater than the size of your existing circuit.

Important

如果现有端口上的容量不足,则可能需要重新创建 ExpressRoute 线路。If there is inadequate capacity on the existing port, you may have to recreate the ExpressRoute circuit. 如果该位置没有额外的可用容量,则不能升级线路。You cannot upgrade the circuit if there is no additional capacity available at that location.

但是,无法在不中断的情况下降低 ExpressRoute 线路的带宽。You cannot reduce the bandwidth of an ExpressRoute circuit without disruption. 带宽降级要求取消对 ExpressRoute 线路的预配,并重新预配新的 ExpressRoute 线路。Downgrading bandwidth requires you to deprovision the ExpressRoute circuit, and then reprovision a new ExpressRoute circuit.

确定所需的大小后,可以使用以下命令调整线路的大小:After you decide the size you need, use the following command to resize your circuit:

az network express-route update -n MyCircuit -g ExpressRouteResourceGroup --bandwidth 1000

线路的大小会在 Microsoft 端进行调整。Your circuit is sized up on the Microsoft side. 接着,必须联系连接服务提供商,让他们在那一端根据此更改更新配置。Next, you must contact your connectivity provider to update configurations on their side to match this change. 在发出此通知后,我们将开始对更新后的带宽选项进行计费。After you make this notification, we begin billing you for the updated bandwidth option.

将 SKU 从按流量计费转为不受限制To move the SKU from metered to unlimited

可以通过使用以下示例更改 ExpressRoute 线路的 SKU:You can change the SKU of an ExpressRoute circuit by using the following example:

az network express-route update -n MyCircuit -g ExpressRouteResourceGroup --sku-family UnlimitedData

控制对经典环境和 Resource Manager 环境的访问To control access to the classic and Resource Manager environments

查看将 ExpressRoute 线路从经典部署模型转移到资源管理器部署模型中的说明。Review the instructions in Move ExpressRoute circuits from the classic to the Resource Manager deployment model.

取消设置和删除 ExpressRoute 线路Deprovisioning and deleting an ExpressRoute circuit

若要取消预配并删除 ExpressRoute 线路,请确保已了解以下条件:To deprovision and delete an ExpressRoute circuit, make sure you understand the following criteria:

  • 必须取消所有虚拟网络与 ExpressRoute 线路的链接。You must unlink all virtual networks from the ExpressRoute circuit. 如果此操作失败,请查看是否有虚拟网络链接到了该线路。If this operation fails, check to see if any virtual networks are linked to the circuit.
  • 如果 ExpressRoute 线路服务提供商预配状态为“正在预配”或“已预配”,则必须与服务提供商合作,在他们那一端取消预配线路 。If the ExpressRoute circuit service provider provisioning state is Provisioning or Provisioned, you must work with your service provider to deprovision the circuit on their side. 在服务提供商取消对线路的预配并通知我们之前,我们会继续保留资源并收费。We continue to reserve resources and bill you until the service provider completes deprovisioning the circuit and notifies us.
  • 如果服务提供商已取消预配线路,则可以删除此线路。You can delete the circuit if the service provider has deprovisioned the circuit. 取消预配线路后,服务提供商预配状态会被设置为“未预配” 。When a circuit is deprovisioned, the service provider provisioning state is set to Not provisioned. 这样就会停止对线路的计费。This stops billing for the circuit.

可以通过运行以下命令删除 ExpressRoute 线路:You can delete your ExpressRoute circuit by running the following command:

az network express-route delete  -n MyCircuit -g ExpressRouteResourceGroup

后续步骤Next steps

创建线路后,请务必执行以下任务:After you create your circuit, make sure that you do the following tasks: