-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.bicep
242 lines (211 loc) · 5.27 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
@description('Name of the VNet')
param virtualNetworkName string = 'vnet1'
@description('Name of the Web Farm')
param serverFarmName string = 'serverfarm'
@description('Web App 1 name must be unique DNS name worldwide')
param site1_Name string = 'webapp1-${uniqueString(resourceGroup().id)}'
@description('Web App 2 name must be unique DNS name worldwide')
param site2_Name string = 'webapp2-${uniqueString(resourceGroup().id)}'
@description('CIDR of your VNet')
param virtualNetwork_CIDR string = '10.200.0.0/16'
@description('Name of the subnet')
param subnet1Name string = 'Subnet1'
@description('Name of the subnet')
param subnet2Name string = 'Subnet2'
@description('CIDR of your subnet')
param subnet1_CIDR string = '10.200.1.0/24'
@description('CIDR of your subnet')
param subnet2_CIDR string = '10.200.2.0/24'
@description('Location for all resources.')
param location string = resourceGroup().location
@description('SKU name, must be minimum P1v2')
@allowed([
'P1v2'
'P2v2'
'P3v2'
])
param skuName string = 'P1v2'
@description('SKU size, must be minimum P1v2')
@allowed([
'P1v2'
'P2v2'
'P3v2'
])
param skuSize string = 'P1v2'
@description('SKU family, must be minimum P1v2')
@allowed([
'P1v2'
'P2v2'
'P3v2'
])
param skuFamily string = 'P1v2'
@description('Name of your Private Endpoint')
param privateEndpointName string = 'PrivateEndpoint1'
@description('Link name between your Private Endpoint and your Web App')
param privateLinkConnectionName string = 'PrivateEndpointLink1'
var webapp_dns_name = '.azurewebsites.net'
var privateDNSZoneName = 'privatelink.azurewebsites.net'
var SKU_tier = 'PremiumV2'
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
virtualNetwork_CIDR
]
}
}
}
resource subnet1 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = {
parent: virtualNetwork
name: subnet1Name
properties: {
addressPrefix: subnet1_CIDR
privateEndpointNetworkPolicies: 'Disabled'
}
}
resource subnet2 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = {
parent: virtualNetwork
name: subnet2Name
dependsOn: [
subnet1
]
properties: {
addressPrefix: subnet2_CIDR
delegations: [
{
name: 'delegation'
properties: {
serviceName: 'Microsoft.Web/serverfarms'
}
}
]
privateEndpointNetworkPolicies: 'Enabled'
}
}
resource serverFarm 'Microsoft.Web/serverfarms@2020-06-01' = {
name: serverFarmName
location: location
sku: {
name: skuName
tier: SKU_tier
size: skuSize
family: skuFamily
capacity: 1
}
kind: 'app'
}
resource webApp1 'Microsoft.Web/sites@2020-06-01' = {
name: site1_Name
location: location
kind: 'app'
properties: {
serverFarmId: serverFarm.id
}
}
resource webApp2 'Microsoft.Web/sites@2020-06-01' = {
name: site2_Name
location: location
kind: 'app'
properties: {
serverFarmId: serverFarm.id
}
}
resource webApp2AppSettings 'Microsoft.Web/sites/config@2020-06-01' = {
parent: webApp2
name: 'appsettings'
properties: {
WEBSITE_DNS_SERVER: '168.63.129.16'
WEBSITE_VNET_ROUTE_ALL: '1'
}
}
resource webApp1Config 'Microsoft.Web/sites/config@2020-06-01' = {
parent: webApp1
name: 'web'
properties: {
ftpsState: 'AllAllowed'
}
}
resource webApp2Config 'Microsoft.Web/sites/config@2020-06-01' = {
parent: webApp2
name: 'web'
properties: {
ftpsState: 'AllAllowed'
}
}
resource webApp1Binding 'Microsoft.Web/sites/hostNameBindings@2019-08-01' = {
parent: webApp1
name: '${webApp1.name}${webapp_dns_name}'
properties: {
siteName: webApp1.name
hostNameType: 'Verified'
}
}
resource webApp2Binding 'Microsoft.Web/sites/hostNameBindings@2019-08-01' = {
parent: webApp2
name: '${webApp2.name}${webapp_dns_name}'
properties: {
siteName: webApp2.name
hostNameType: 'Verified'
}
}
resource webApp2NetworkConfig 'Microsoft.Web/sites/networkConfig@2020-06-01' = {
parent: webApp2
name: 'virtualNetwork'
properties: {
subnetResourceId: subnet2.id
}
}
resource privateEndpoint 'Microsoft.Network/privateEndpoints@2020-06-01' = {
name: privateEndpointName
location: location
properties: {
subnet: {
id: subnet1.id
}
privateLinkServiceConnections: [
{
name: privateLinkConnectionName
properties: {
privateLinkServiceId: webApp1.id
groupIds: [
'sites'
]
}
}
]
}
}
resource privateDnsZones 'Microsoft.Network/privateDnsZones@2018-09-01' = {
name: privateDNSZoneName
location: 'global'
dependsOn: [
virtualNetwork
]
}
resource privateDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' = {
parent: privateDnsZones
name: '${privateDnsZones.name}-link'
location: 'global'
properties: {
registrationEnabled: false
virtualNetwork: {
id: virtualNetwork.id
}
}
}
resource privateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-03-01' = {
parent: privateEndpoint
name: 'dnsgroupname'
properties: {
privateDnsZoneConfigs: [
{
name: 'config1'
properties: {
privateDnsZoneId: privateDnsZones.id
}
}
]
}
}