-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd-Tags2RT.ps1
More file actions
33 lines (23 loc) · 1.01 KB
/
Add-Tags2RT.ps1
File metadata and controls
33 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$rt_name = "split_route"
$rg_name = "rg_tb_batch"
$region = "eastus"
$servicetags = "BatchNodeManagement.EastUS"
$tags = Get-AzNetworkServiceTag -Location $region
$batchprefixes = $tags.Values | ? {$_.Name -eq $servicetags}
$myroutetable = Get-AzRouteTable -ResourceGroupName $rg_name -Name $rt_name
$prefcount = $batchprefixes.Properties.AddressPrefixes.count
$totalcount = $prefcount
if ($totalcount -ge 400) {
Write-Host "There are $prefcount prefixes for $servicetags. Too many routes to add. Aborting now."
Exit
}
$i=0
foreach ($prefix in $batchprefixes.Properties.AddressPrefixes) {
$route_name = "BatchNodeMgmt_" + $prefix.Replace("/","_").Replace(":",".") + "_nexthopInternet"
Add-AzRouteConfig -RouteTable $myroutetable -Name $route_name -AddressPrefix $prefix -NextHopType Internet
$i++
Write-Host "Added $i route of $prefcount ..." -ForegroundColor Yellow
}
Write-Host "Committing..."
Set-AzRouteTable -RouteTable $myroutetable
Write-Host "Finished"