你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

使用 Azure CLI 配置路由首选项以影响路由选择

了解如何使用 Azure 路由服务器中的路由首选项设置来影响其路由学习和选择。 有关详细信息,请参阅路由首选项(预览版)

重要

路由首选项目前为预览版。 有关 beta 版本、预览版或尚未正式发布的版本的 Azure 功能所适用的法律条款,请参阅 Microsoft Azure 预览版的补充使用条款

先决条件

查看路由首选项配置

使用 az network routeserver show 可查看当前路由服务器配置,包括其路由首选项设置。

# Show the Route Server configuration.
az network routeserver show --resource-group 'myResourceGroup' --name 'myRouteServer'

在输出中,可以在“hubRoutingPreference”前面看到当前路由首选项设置:

{
  "allowBranchToBranchTraffic": false,
  "etag": "W/\"00000000-1111-2222-3333-444444444444\"",
  "hubRoutingPreference": "ExpressRoute",
  "id": "/subscriptions/abcdef01-2345-6789-0abc-def012345678/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualHubs/myRouteServer",
  "kind": "RouteServer",
  "location": "eastus",
  "name": "myRouteServer",
  "provisioningState": "Succeeded",
  "resourceGroup": "myResourceGroup",
  "routeTable": {
    "routes": []
  },
  "routingState": "Provisioned",
  "sku": "Standard",
  "tags": {},
  "type": "Microsoft.Network/virtualHubs",
  "virtualHubRouteTableV2s": [],
  "virtualRouterAsn": 65515,
  "virtualRouterAutoScaleConfiguration": {
    "minCapacity": 2
  },
  "virtualRouterIps": [
    "10.1.1.5",
    "10.1.1.4"
  ]
}

注意

默认路由首选项设置为 ExpressRoute

配置路由首选项

使用 az network routeserver update 可更新路由首选项设置。

# Change the routing preference to AS Path.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'ASPath' --resource-group 'myResourceGroup'
# Change the routing preference to VPN Gateway.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'VpnGateway' --resource-group 'myResourceGroup'
# Change the routing preference to ExpressRoute.
az network routeserver update --name 'myRouteServer' --hub-routing-preference 'ExpressRoute' --resource-group 'myResourceGroup'