使用 Azure 资源管理器模板创建 ExpressRoute 线路Create an ExpressRoute circuit by using Azure Resource Manager template

了解如何使用 Azure PowerShell 部署 Azure 资源管理器模板,以便创建 ExpressRoute 线路。Learn how to create an ExpressRoute circuit by deploying an Azure Resource Manager template by using Azure PowerShell. 有关开发资源管理器模板的详细信息,请参阅资源管理器文档模板参考For more information on developing Resource Manager templates, see Resource Manager documentation and the template reference.

准备阶段Before you begin

  • 在开始配置之前,请查看先决条件工作流Review the prerequisites and workflows before you begin configuration.
  • 确保有权创建新的网络资源。Ensure that you have permissions to create new networking resources. 如果没有适当的权限,请与帐户管理员联系。Contact your account administrator if you do not have the right permissions.

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

Azure 快速入门模板有许多资源管理器模板。Azure Quickstart templates has a good collection of Resource Manager template. 请使用某个现有模板来创建 ExpressRoute 线路。You use one of the existing templates to create an ExpressRoute circuit.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "circuitName": {
      "type": "string",
      "metadata": {
        "description": "This is the name of the ExpressRoute circuit"
      }
    },
    "serviceProviderName": {
      "type": "string",
      "metadata": {
        "description": "This is the name of the ExpressRoute Service Provider. It must exactly match one of the Service Providers from List ExpressRoute Service Providers API call."
      }
    },
    "peeringLocation": {
      "type": "string",
      "metadata": {
        "description": "This is the name of the peering location and not the ARM resource location. It must exactly match one of the available peering locations from List ExpressRoute Service Providers API call."
      }
    },
    "bandwidthInMbps": {
      "type": "int",
      "metadata": {
        "description": "This is the bandwidth in Mbps of the circuit being created. It must exactly match one of the available bandwidth offers List ExpressRoute Service Providers API call."
      }
    },
    "sku_tier": {
      "type": "string",
      "defaultValue": "Standard",
      "allowedValues": [
        "Standard",
        "Premium"
      ],
      "metadata": {
        "description": "Chosen SKU Tier of ExpressRoute circuit. Choose from Premium or Standard SKU tiers."
      }
    },
    "sku_family": {
      "type": "string",
      "defaultValue": "MeteredData",
      "allowedValues": [
        "MeteredData",
        "UnlimitedData"
      ],
      "metadata": {
        "description": "Chosen SKU family of ExpressRoute circuit. Choose from MeteredData or UnlimitedData SKU families."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2019-04-01",
      "type": "Microsoft.Network/expressRouteCircuits",
      "name": "[parameters('circuitName')]",
      "location": "[parameters('location')]",
      "tags": {
        "key1": "value1",
        "key2": "value2"
      },
      "sku": {
        "name": "[concat(parameters('sku_tier'),'_', parameters('sku_family'))]",
        "tier": "[parameters('sku_tier')]",
        "family": "[parameters('sku_family')]"
      },
      "properties": {
        "serviceProviderProperties": {
          "serviceProviderName": "[parameters('serviceProviderName')]",
          "peeringLocation": "[parameters('peeringLocation')]",
          "bandwidthInMbps": "[parameters('bandwidthInMbps')]"
        }
      }
    }
  ]
}

若要查看更多相关的模板,请在此处进行选择。To see more related templates, select here.

若要通过部署模板来创建 ExpressRoute 线路,请执行以下操作:To create an ExpressRoute Circuit by deploying a template:

  1. 按说明登录到 Azure。Follow the instructions to sign in to the Azure.

    $circuitName = Read-Host -Prompt "Enter a circuit name"
    $location = Read-Host -Prompt "Enter the location (i.e. chinaeast)"
    $resourceGroupName = "${circuitName}rg"
    $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-expressroute-circuit-create/azuredeploy.json"
    
    $serviceProviderName = "Shanghai Telecom Ethernet"
    $peeringLocation = "Shanghai"
    $bandwidthInMbps = 500
    $sku_tier = "Premium"
    $sku_family = "MeteredData"
    
    New-AzResourceGroup -Name $resourceGroupName -Location $location
    New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -circuitName $circuitName -serviceProviderName $serviceProviderName -peeringLocation $peeringLocation -bandwidthInMbps $bandwidthInMbps -sku_tier $sku_tier -sku_family $sku_family
    
    Write-Host "Press [ENTER] to continue ..."
    
    • SKU 层确定 ExpressRoute 线路是本地线路、标准线路还是高级线路。SKU tier determines whether an ExpressRoute circuit is Local, Standard or Premium. 可以指定“本地” 、“标准” 或“高级” 。You can specify Local, Standard or Premium.

    • 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. “本地” 线路仅为 Unlimiteddata 。A Local circuit is Unlimiteddata only.

    • “对等互连位置” 是与 Microsoft 建立对等互连的实际位置。Peering Location is the physical location where you are peering with Microsoft.

      Important

      “对等互连位置”指明了与 Microsoft 建立对等互连的实际位置The Peering Location indicates the physical location where you are peering with Microsoft. 此位置与“Location”属性 没有 关系,后者指的是 Azure 网络资源提供商所在的地理位置。This is not linked to "Location" property, which refers to the geography where the Azure Network Resource Provider is located. 尽管两者之间没有关系,但最好是选择地理上与线路对等互连位置靠近的网络资源提供商。While they are not related, it is a good practice to choose a Network Resource Provider geographically close to the Peering Location of the circuit.

    资源组名称是追加了 rg 的服务总线命名空间名称。The resource group name is the service bus namespace name with rg appended.

  2. 选择“复制”以复制 PowerShell 脚本。 Select Copy to copy the PowerShell script.

  3. 右键单击 shell 控制台,然后选择“粘贴” 。Right-click the shell console, and then select Paste.

创建事件中心需要一些时间。It takes a few moments to create an event hub.

在本教程中,请使用 Azure PowerShell 来部署模板。Azure PowerShell is used to deploy the template in this tutorial. 如需其他模板部署方法,请参阅:For other template deployment methods, see:

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

可以通过选择“删除” 图标来删除 ExpressRoute 线路。You can delete your ExpressRoute circuit by selecting the delete icon. 请注意以下信息:Note the following information:

  • 必须取消所有虚拟网络与 ExpressRoute 线路的链接。You must unlink all virtual networks from the ExpressRoute circuit. 如果此操作失败,请检查是否有虚拟网络链接到了该线路。If this operation fails, check whether 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.
  • 如果服务提供商已取消设置线路(服务提供商预配状态设置为“未预配” ),可以删除线路。If the service provider has deprovisioned the circuit (the service provider provisioning state is set to Not provisioned), you can delete the circuit. 这样就会停止对线路的计费。This stops billing for the circuit.

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

$circuitName = Read-Host -Prompt "Enter the same circuit name that you used earlier"
$resourceGroupName = "${circuitName}rg"

Remove-AzExpressRouteCircuit -ResourceGroupName $resourceGroupName -Name $circuitName

后续步骤Next steps

创建线路后,请继续执行以下后续步骤:After you create your circuit, continue with the following next steps: