共用方式為


快速入門:使用 ARM 範本建立 Azure 路由伺服器

此快速入門將幫助您了解如何使用 Azure Resource Manager 範本 (ARM 範本),將 Azure 路由伺服器部署到新的或現有的虛擬網路。

Azure Resource Manager 範本是一個 JavaScript 物件標記法 (JSON) 檔案,會定義專案的基礎結構和設定。 範本使用宣告式語法。 您可以描述預期的部署,而不需要撰寫程式設計命令順序來建立部署。

如果您的環境符合必要條件,而且您很熟悉 ARM 範本的使用方式,請選取 [部署至 Azure] 按鈕,在 Azure 入口網站中開啟該範本。

將 Resource Manager 範本部署至 Azure 的按鈕。

必要條件

檢閱範本

本快速入門中使用的範本是來自 Azure 快速入門範本

使用此範本,您會將 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/27",
      "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 資源:

如需更多範本,請參閱 Azure 快速入門範本

部署範本

  1. 選取以下程式碼區塊的 [開啟 Cloudshell] 以開啟 Azure Cloud Shell,然後遵循指示登入 Azure。

    $projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names"
    $location = Read-Host -Prompt "Enter the location (i.e. centralus)"
    $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 ..."
    

    等候直到您看見主控台的提示字元。

  2. 從先前的程式碼區塊選取 [複製] 以複製 PowerShell 指令碼。

  3. 以滑鼠右鍵按一下殼層主控台窗格,然後選取 [貼上]

  4. 輸入這些值。

    資源群組名稱是附加 rg 的專案名稱。

    部署範本需要約 20 分鐘。 完成時,輸出如下:

    路由伺服器 Resource Manager 範本 PowerShell 部署輸出。

Azure PowerShell 用於部署範本。 除了 Azure PowerShell 以外,您也可以使用 Azure 入口網站、Azure CLI 和 REST API。 若要了解其他部署方法,請參閱部署範本

驗證部署

  1. 登入 Azure 入口網站

  2. 選取左側面板中的 [資源群組]

  3. 選取您在上一節中建立的資源群組。 預設的資源群組名稱是附加 rg 的專案名稱。

  4. 資源群組應該只包含虛擬網路:

    與虛擬網路搭配使用的路由伺服器部署資源群組。

  5. 移至 https://aka.ms/routeserver

  6. 選取名為 routeserver 的路由伺服器,以確認部署成功。

    路由伺服器概觀頁面的螢幕擷取畫面。

清除資源

當您不再需要透過路由伺服器建立的資源時,請刪除資源群組,藉此移除路由伺服器和所有相關資源。

若要刪除資源群組,請使用 Remove-AzResourceGroup Cmdlet:

Remove-AzResourceGroup -Name <your resource group name>

後續步驟