/
DeployVms_Repeat.bicep
130 lines (120 loc) · 2.84 KB
/
DeployVms_Repeat.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
param resourceNamePrefix string
param location string = resourceGroup().location
param adminUserName string
@secure()
param adminUserPassword string
param numberOfWindows int
param numberOfUbuntu int
resource vnet 'Microsoft.Network/virtualNetworks@2022-01-01' = {
name: '${resourceNamePrefix}-vnet'
location: location
properties: {
addressSpace: {
addressPrefixes: [
'172.16.0.0/16'
]
}
subnets: [
{
name: 'Subnet-1'
properties: {
addressPrefix: '172.16.0.0/24'
networkSecurityGroup: {
id: NSG1.id
}
}
}
{
name: 'Subnet-2'
properties: {
addressPrefix: '172.16.1.0/24'
networkSecurityGroup: {
id: NSG2.id
}
}
}
{
name: 'Subnet-3'
properties: {
addressPrefix: '172.16.3.0/24'
networkSecurityGroup: {
id: NSG3.id
}
}
}
{
name: 'AzureBastionSubnet'
properties: {
addressPrefix: '172.16.253.0/24'
}
}
{
name: 'AzureFirewallSubnet'
properties: {
addressPrefix: '172.16.254.0/24'
}
}
{
name: 'GatewaySubnet'
properties: {
addressPrefix: '172.16.255.0/24'
}
}
]
}
resource Subnet1 'subnets' existing = {
name: 'Subnet-1'
}
resource Subnet2 'subnets' existing = {
name: 'Subnet-2'
}
resource Subnet3 'subnets' existing = {
name: 'Subnet-3'
}
}
resource NSG1 'Microsoft.Network/networkSecurityGroups@2022-01-01' = {
name: '${resourceNamePrefix}-NSG-1'
location: location
properties: {
securityRules: [
]
}
}
resource NSG2 'Microsoft.Network/networkSecurityGroups@2022-01-01' = {
name: '${resourceNamePrefix}-NSG-2'
location: location
properties: {
securityRules: [
]
}
}
resource NSG3 'Microsoft.Network/networkSecurityGroups@2022-01-01' = {
name: '${resourceNamePrefix}-NSG-3'
location: location
properties: {
securityRules: [
]
}
}
module WinVmModule '../module/deploy-windows.bicep' = [for i in range(0, numberOfWindows): {
name: '${resourceNamePrefix}-winVmDeploy${padLeft(i+1, 3, '0')}'
params: {
adminPassword: adminUserPassword
adminUserName: adminUserName
location: location
vmName: '${resourceNamePrefix}-WinVM${padLeft(i+1, 3, '0')}'
subnetId: vnet::Subnet1.id
vmSize: 'Standard_B2ms'
}
}]
module UbuVmModule '../module/deploy-ubuntu.bicep' = [for i in range(0, numberOfUbuntu): {
name: '${resourceNamePrefix}-ubuVmDeploy${padLeft(i+1, 3, '0')}'
params: {
adminPassword: adminUserPassword
adminUserName: adminUserName
location: location
vmName: '${resourceNamePrefix}-UbuVM${padLeft(i+1, 3, '0')}'
subnetId: vnet::Subnet2.id
vmSize: 'Standard_B1ms'
}
}]