/
virtual-network.bicep
62 lines (59 loc) · 1.36 KB
/
virtual-network.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
param location string = resourceGroup().location
param virtualNetworkName string = 'my-vnet'
param virtualNetworkAddressPrefix string = '10.0.0.0/16'
param subnets array = [
{
name: 'Web'
addressPrefix: '10.0.0.0/24'
allowRdp: false
}
{
name: 'JumpBox'
addressPrefix: '10.0.1.0/24'
allowRdp: true
}
]
var subnetsToCreate = [for item in subnets: {
name: item.name
properties: {
addressPrefix: item.addressPrefix
networkSecurityGroup: item.allowRdp ? {
id: nsgAllowRdp.id
} : null
}
}]
var nsgAllowRdpName = 'nsg-allow-rdp'
resource nsgAllowRdp 'Microsoft.Network/networkSecurityGroups@2022-11-01' = {
name: nsgAllowRdpName
location: location
properties: {
securityRules: [
{
name: 'allow-rdp'
properties: {
description: 'Allow RDP'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '3389'
sourceAddressPrefix: 'Internet'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 100
direction: 'Inbound'
}
}
]
}
}
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-11-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
virtualNetworkAddressPrefix
]
}
subnets: subnetsToCreate
}
}