本快速入门介绍如何使用 Azure 资源管理器模板(ARM 模板)将 Azure 路由服务器部署到新的或现有的虚拟网络中。 Azure 路由服务器通过 BGP 对等互连在虚拟网络与网络虚拟设备之间启用动态路由,从而自动管理网络基础结构中的路由交换。
完成本快速入门后,你将使用必要的网络基础结构部署一个正常运行的路由服务器,并准备好进行 BGP 对等互连配置。
Azure 资源管理器模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。 模板使用声明性语法。 你可以在不编写用于创建部署的编程命令序列的情况下,描述预期部署。
如果环境满足先决条件并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮以在 Azure 门户中打开模板。
先决条件
在开始之前,请确保满足以下要求:
- 具有活动订阅的 Azure 帐户。 创建试用帐户。
- 熟悉 Azure 路由服务器服务限制。
查看模板
本快速入门中使用的模板来自 Azure 快速启动模板。 此 ARM 模板部署完整的路由服务器环境,包括虚拟网络基础结构和 BGP 对等互连配置。
该模板创建以下资源:
- 新虚拟网络或现有虚拟网络中的 Azure 路由服务器
- 名为 RouteServerSubnet 的专用子网用于托管路由服务器
- 具有指定对等 ASN 和对等 IP 的 BGP 对等互连配置
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "3572840517141664306"
}
},
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "routeservervnet",
"metadata": {
"description": "Name of new or existing vnet to which Azure Route Server should be deployed."
}
},
"vnetIpPrefix": {
"type": "string",
"defaultValue": "10.1.0.0/16",
"metadata": {
"description": "IP prefix for available addresses in vnet address space."
}
},
"vnetNew_or_Existing": {
"type": "string",
"defaultValue": "New",
"allowedValues": [
"New",
"Existing"
],
"metadata": {
"description": "Specify whether to provision new vnet or deploy to existing vnet."
}
},
"routeServerSubnetIpPrefix": {
"type": "string",
"defaultValue": "10.1.1.0/26",
"metadata": {
"description": "Route Server subnet IP prefix MUST be within vnet IP prefix address space."
}
},
"publicIpNew_or_Existing": {
"type": "string",
"defaultValue": "New",
"allowedValues": [
"New",
"Existing"
],
"metadata": {
"description": "Specify whether to provision new standard public IP or deploy using existing standard public IP."
}
},
"publicIpName": {
"type": "string",
"defaultValue": "routeserverpip",
"metadata": {
"description": "Name of the standard Public IP used for the Route Server"
}
},
"firstRouteServerName": {
"type": "string",
"defaultValue": "routeserver",
"metadata": {
"description": "Name of Route Server."
}
},
"routeServerBgpConnectionName": {
"type": "string",
"defaultValue": "conn1",
"metadata": {
"description": "Name of BGP connection."
}
},
"peerAsn": {
"type": "int",
"defaultValue": 65002,
"metadata": {
"description": "Peer ASN connecting to."
}
},
"peerIp": {
"type": "string",
"defaultValue": "10.0.1.4",
"metadata": {
"description": "Peer IP connecting to."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Azure region for Route Server and virtual network."
}
}
},
"variables": {
"ipconfigName": "ipconfig1",
"routeServerSubnetName": "RouteServerSubnet"
},
"resources": [
{
"condition": "[equals(parameters('vnetNew_or_Existing'), 'New')]",
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetIpPrefix')]"
]
}
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2020-05-01",
"name": "[format('{0}/{1}', parameters('vnetName'), variables('routeServerSubnetName'))]",
"properties": {
"addressPrefix": "[parameters('routeServerSubnetIpPrefix')]"
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
]
},
{
"condition": "[equals(parameters('publicIpNew_or_Existing'), 'New')]",
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-05-01",
"name": "[parameters('publicIpName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"publicIPAllocationMethod": "Static",
"publicIPAddressVersion": "IPv4",
"idleTimeoutInMinutes": 4
}
},
{
"type": "Microsoft.Network/virtualHubs",
"apiVersion": "2020-06-01",
"name": "[parameters('firstRouteServerName')]",
"location": "[parameters('location')]",
"properties": {
"sku": "Standard"
}
},
{
"type": "Microsoft.Network/virtualHubs/ipConfigurations",
"apiVersion": "2020-06-01",
"name": "[format('{0}/{1}', parameters('firstRouteServerName'), variables('ipconfigName'))]",
"properties": {
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), variables('routeServerSubnetName'))]"
},
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualHubs', parameters('firstRouteServerName'))]",
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]",
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), variables('routeServerSubnetName'))]"
]
},
{
"type": "Microsoft.Network/virtualHubs/bgpConnections",
"apiVersion": "2020-06-01",
"name": "[format('{0}/{1}', parameters('firstRouteServerName'), parameters('routeServerBgpConnectionName'))]",
"properties": {
"peerAsn": "[parameters('peerAsn')]",
"peerIp": "[parameters('peerIp')]"
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualHubs', parameters('firstRouteServerName'))]",
"[resourceId('Microsoft.Network/virtualHubs/ipConfigurations', parameters('firstRouteServerName'), variables('ipconfigName'))]"
]
}
]
}
模板资源
模板中定义了以下 Azure 资源:
- Microsoft.Network/virtualNetworks - 用于托管路由服务器的虚拟网络
- Microsoft.Network/virtualNetworks/subnets - 两个子网,包括所需的 RouteServerSubnet
- Microsoft.Network/virtualHubs - 路由服务器部署资源
- Microsoft.Network/virtualHubs/ipConfigurations - 路由服务器的 IP 配置
- Microsoft.Network/virtualHubs/bgpConnections - 具有对等 ASN 和对等 IP 的 BGP 对等互连配置
若要查找与 Azure 网络相关的更多模板,请参阅 Azure 快速入门模板。
部署模板
可以通过 Azure PowerShell 使用 Azure PowerShell 部署模板。
$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names" $location = Read-Host -Prompt "Enter the location (i.e. chinanorth3)" $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/route-server/azuredeploy.json" $resourceGroupName = "${projectName}rg" New-AzResourceGroup -Name $resourceGroupName -Location "$location" New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri Read-Host -Prompt "Press [ENTER] to continue ..."
等到控制台中显示提示。
从上一个代码块中选择 “复制” 以复制 PowerShell 脚本。
右键单击 shell 控制台窗格,然后选择“粘贴”。
出现提示时输入值:
- 项目名称:用于生成资源名称(资源组名称将是追加 了 rg 的项目名称)
- 位置:将部署资源的 Azure 区域
部署大约需要 20 分钟才能完成。 完成后,输出应类似于:
Azure PowerShell 用于在此示例中部署模板。 还可以使用 Azure 门户、Azure CLI 和 REST API 进行模板部署。 若要了解其他部署方法,请参阅 “部署模板”。
验证部署
模板部署完成后,验证路由服务器是否已成功创建。
在 Azure 门户中验证资源
登录 Azure 门户。
从左侧窗格中选择“资源组”。
选择你在上一部分中创建的资源组。 默认资源组名称是追加了 rg 的项目名称。
资源组应包含虚拟网络和关联的资源:
验证路由服务器部署
在 Azure 门户中,导航到资源组并选择路由服务器资源。
在“路由服务器概述”页上,验证以下内容:
- 状态 显示为“成功”
- BGP ASN 显示配置的自治系统编号
- 路由状态 显示为“已预配”
清理资源
如果不再需要路由服务器和关联的资源,请删除资源组以删除路由服务器和所有相关资源。
若要删除资源组,请使用 Remove-AzResourceGroup cmdlet:
Remove-AzResourceGroup -Name <your resource group name>
下一步
使用 ARM 模板部署路由服务器后,请详细了解路由服务器功能: