-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.bicep
172 lines (157 loc) · 4.23 KB
/
main.bicep
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@description('Virtual Network name')
param virtualNetworkName string = 'Application-Vnet'
@description('Virtual Network address range')
param vnetAddressPrefix string = '10.0.0.0/16'
@description('Name of the subnet')
param subnetName string = 'ApplicationGatewaySubnet'
@description('Subnet address range')
param subnetPrefix string = '10.0.0.0/24'
@description('Application Gateway name')
param applicationGatewayName string = 'applicationGatewayV2'
@description('Minimum instance count for Application Gateway')
param minCapacity int = 2
@description('Maximum instance count for Application Gateway')
param maxCapacity int = 10
@description('Application Gateway Frontend port')
param frontendPort int = 80
@description('Application gateway Backend port')
param backendPort int = 80
@description('Back end pool ip addresses')
param backendIPAddresses array = [
{
IpAddress: '10.0.0.4'
}
{
IpAddress: '10.0.0.5'
}
]
@description('Cookie based affinity')
@allowed([
'Enabled'
'Disabled'
])
param cookieBasedAffinity string = 'Disabled'
@description('Location for all resources.')
param location string = resourceGroup().location
var appGwPublicIpName = '${applicationGatewayName}-pip'
var appGwSize = 'Standard_v2'
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
vnetAddressPrefix
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: subnetPrefix
}
}
]
}
}
resource publicIP 'Microsoft.Network/publicIPAddresses@2020-06-01' = {
name: appGwPublicIpName
location: location
sku: {
name: 'Standard'
}
properties: {
publicIPAllocationMethod: 'Static'
}
}
resource applicationGateway 'Microsoft.Network/applicationGateways@2020-06-01' = {
name: applicationGatewayName
location: location
properties: {
sku: {
name: appGwSize
tier: 'Standard_v2'
}
autoscaleConfiguration: {
minCapacity: minCapacity
maxCapacity: maxCapacity
}
gatewayIPConfigurations: [
{
name: 'appGatewayIpConfig'
properties: {
subnet: {
id: resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetwork.name, subnetName)
}
}
}
]
frontendIPConfigurations: [
{
name: 'appGatewayFrontendIP'
properties: {
publicIPAddress: {
id: publicIP.id
}
}
}
]
frontendPorts: [
{
name: 'appGatewayFrontendPort'
properties: {
port: frontendPort
}
}
]
backendAddressPools: [
{
name: 'appGatewayBackendPool'
properties: {
backendAddresses: backendIPAddresses
}
}
]
backendHttpSettingsCollection: [
{
name: 'appGatewayBackendHttpSettings'
properties: {
port: backendPort
protocol: 'Http'
cookieBasedAffinity: cookieBasedAffinity
}
}
]
httpListeners: [
{
name: 'appGatewayHttpListener'
properties: {
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/applicationGateways/frontendIPConfigurations', applicationGatewayName, 'appGatewayFrontendIP')
}
frontendPort: {
id: resourceId('Microsoft.Network/applicationGateways/frontendPorts', applicationGatewayName, 'appGatewayFrontendPort')
}
protocol: 'Http'
}
}
]
requestRoutingRules: [
{
name: 'rule1'
properties: {
ruleType: 'Basic'
httpListener: {
id: resourceId('Microsoft.Network/applicationGateways/httpListeners', applicationGatewayName, 'appGatewayHttpListener')
}
backendAddressPool: {
id: resourceId('Microsoft.Network/applicationGateways/backendAddressPools', applicationGatewayName, 'appGatewayBackendPool')
}
backendHttpSettings: {
id: resourceId('Microsoft.Network/applicationGateways/backendHttpSettingsCollection', applicationGatewayName, 'appGatewayBackendHttpSettings')
}
}
}
]
}
}