-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path04_01_Deploy-Networking.ps1
46 lines (39 loc) · 1.44 KB
/
04_01_Deploy-Networking.ps1
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
34
35
36
37
38
39
40
41
42
43
44
45
46
#Define Deployment Variables
$appNamePrefix = 'tws'
$locationDetails = Get-Content -Path './locationDetails.json' | ConvertFrom-Json
#Deploy Resource Groups
foreach ($i in $locationDetails) {
$location = $i.Location
$resourceGroupName = "$appNamePrefix-iaas-$location"
New-AzResourceGroup -Name $resourceGroupName -Location $location -Force
}
#Deploy Virtual Networks
foreach ($i in $locationDetails) {
$location = $i.Location
$vNetName = "$appNamePrefix-vnet-$location"
$resourceGroupName = "$appNamePrefix-iaas-$location"
$vNetAddressPrefix = $i.AddressPrefix
New-AzVirtualNetwork `
-Name $vNetName `
-Location $location `
-ResourceGroupName $resourceGroupName `
-AddressPrefix $vNetAddressPrefix
}
#Deploy Virtual Network Subnets
foreach ($i in $locationDetails) {
$location = $i.Location
$vNetName = "$appNamePrefix-vnet-$location"
$resourceGroupName = "$appNamePrefix-iaas-$location"
$vNetAddressPrefix = $i.AddressPrefix
$subnetDetails = $i.Subnets
foreach ($subnet in $subnetDetails) {
$subnetName = $subnet.Name
$subnetPrefix = $subnet.SubnetPrefix
$vNet = Get-AzVirtualNetwork -Name $vNetName -ResourceGroupName $resourceGroupName
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
-Name $subnetName `
-AddressPrefix $subnetPrefix `
-VirtualNetwork $vNet
$vNet | Set-AzVirtualNetwork
}
}