-
Notifications
You must be signed in to change notification settings - Fork 7
/
ARM - Application Gateway - Delete.ps1
97 lines (52 loc) · 2.32 KB
/
ARM - Application Gateway - Delete.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<# Application Gateway #>
# Variables - Application Gateway
$agwShortName = "aabbccdd12"
$agwSuffix = "-agw"
$agwName = "${agwShortName}${agwSuffix}"
<# Create Application Gateway, if it does not exist #>
Get-AzureRmApplicationGateway -Name $agwName -ErrorVariable isAGWExist -ErrorAction SilentlyContinue `
If ($isAGWExist)
{
Write-Output "Application Gateway does not exist"
Write-Verbose "Create the IP configurations and frontend port"
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetFullName
$publicIP = Get-AzureRmPublicIPAddress -ResourceGroupName $rgName -Name $publicIpFullName
$subnet = $vnet.Subnets[0]
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name myAGIPConfig -Subnet $subnet
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name myAGFrontendIPConfig -PublicIPAddress $publicIP
$frontendport = New-AzureRmApplicationGatewayFrontendPort -Name myFrontendPort -Port 80
Write-Verbose "Creating new Application Gateway: {$agwName}"
$agw = New-AzureRmApplicationGateway `
-Name $agwName `
-ResourceGroupName $rgName `
-Location $location `
-BackendAddressPools $backendPool `
-BackendHttpSettingsCollection $poolSettings `
-FrontendIpConfigurations $fipconfig `
-GatewayIpConfigurations $gipconfig `
-FrontendPorts $frontendport `
-HttpListeners $defaultlistener `
-RequestRoutingRules $frontendRule `
-Sku $sku
}
Else
{
Write-Output "Application Gateway exist"
Write-Verbose "Fetching Application Gateway: {$agwName}"
$agw = Get-AzureRmApplicationGateway `
-Name $agwName
}
Write-Verbose "Get list of Application Gateway"
Write-Output "Application Gateways"
Get-AzureRmApplicationGateway -ResourceGroupName $rgName `
| Select-Object Name, ResourceGroupName, Location `
| Format-Table -AutoSize -Wrap
<#
Get-AzureRmApplicationGateway `
| Select-Object Name, ResourceGroupName, Location `
| Format-Table -AutoSize -Wrap -GroupBy ResourceGroupName
#>
<#
https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-create-gateway-arm
#>