有没有办法使用 PowerShell 脚本访问 Azure 路由 table 的路由?
Is there a way to access an Azure route table's routes with a PowerShell script?
例如,假设我有一条名为 "MyRouteTable" 的路线 table,这条路线 table 有十条路线。我想为这些路由中的每一个分配一个新的 NextHopAddress。
有没有办法使用 PowerShell 脚本以编程方式获取这些路由,以便我可以遍历它们?
您可以使用如下命令获取所有路由名称:
$table = Get-AzureRmRouteTable -ResourceGroupName "TestGP" -Name "routetable"
# All the routes name will be stored in $routes
$routes = @()
foreach ($routeName in $table.Routes)
{
$routes += $i.Name
}
# Custom code here
然后你可以循环路由名称并更新路由,如:
foreach ($routeName in $routes)
{
Set-AzureRmRouteConfig -Name $routeName -RouteTable $table -AddressPrefix <address prefix> -NextHopType <type>
}
# Sets the goal state for route table
Set-AzureRmRouteTable -RouteTable $table
例如,假设我有一条名为 "MyRouteTable" 的路线 table,这条路线 table 有十条路线。我想为这些路由中的每一个分配一个新的 NextHopAddress。
有没有办法使用 PowerShell 脚本以编程方式获取这些路由,以便我可以遍历它们?
您可以使用如下命令获取所有路由名称:
$table = Get-AzureRmRouteTable -ResourceGroupName "TestGP" -Name "routetable"
# All the routes name will be stored in $routes
$routes = @()
foreach ($routeName in $table.Routes)
{
$routes += $i.Name
}
# Custom code here
然后你可以循环路由名称并更新路由,如:
foreach ($routeName in $routes)
{
Set-AzureRmRouteConfig -Name $routeName -RouteTable $table -AddressPrefix <address prefix> -NextHopType <type>
}
# Sets the goal state for route table
Set-AzureRmRouteTable -RouteTable $table