-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.bicep
321 lines (306 loc) · 13 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
targetScope = 'subscription'
//Define AVD deployment parameters
param resourceGroupPrefix string = 'BICEP-AVD-GAMING-DEMO-'
param resourceGroupPostfix string = '-RG'
param AVDbackplanelocation string = 'westeurope'
param hostPoolType string = 'pooled'
param loadBalancerType string = 'BreadthFirst'
param hostpoolFriendlyName string = 'Hostpool with AVD Gaming Desktop'
param appgroupDesktopFriendlyName string = 'AppGroup with AVD Gaming Desktop'
param workspaceFriendlyName string = 'AVD Gaming Demo'
param hostpoolName string = 'BICEP-AVD-HP-DEMO'
param appgroupName string = 'BICEP-AVD-AG-DEMO'
param workspaceName string = 'BICEP-AVD-WS-DEMO'
param preferredAppGroupType string = 'Desktop'
//define log analytics parameters
param logAnalyticsWorkspaceName string = 'BICEP-AVD-DEMO-3'
param logAnalyticsWorkspaceSku string = 'pergb2018'
//Define Networking deployment parameters
param vnetName string = 'BICEP-AVD-GAMING-VNET'
param vnetaddressPrefix string = '10.80.0.0/16'
param subnetPrefix string = '10.80.10.0/24'
param subnetName string = 'BICEP-AVD-GAMING-SUBNET'
param dnsServer string = '10.50.1.4'
//define peering parameters
param createPeering bool = true
param remoteVnetName string = 'NINJA-WE-P-VNET-10-50-0-0-16'
param remoteVnetRg string = 'NINJA-WE-P-RG-NETWORK'
//define session host parameters
param vmNameprefix string = 'AVD-Gaming'
@allowed([
'Nvidia'
'AMD'
])
param gpuType string = 'Nvidia'
param vmSize string = 'Standard_NV6'
param avSetName string = 'avsetdemo'
param ouLocationWVDSessionHost string = 'OU=Bicep-demo,OU=WVD-SpringRelease,OU=Servers,OU=NINJA,DC=wvd,DC=ninja'
param domainJoinUSer string = '[email protected]'
@secure()
param secretValueDomainJoin string
param adDomainName string = 'wvd.ninja'
@secure()
param secretValueLocalAdminPassword string
// Scaling plan & schedule parameters
param scalingPlanDescription string = 'Demo scaling plan'
param scalingPlanExclusionTag string = 'ExcludeTag'
param scalingPlanFriendlyName string = 'This is a demo scaling plan'
@allowed([
'Pooled'
])
param scalingPlanHostPoolType string = 'Pooled'
param scalingPlanLocation string = 'westeurope'
param scalingPlanName string = 'BicepDemoScalingPlan'
param scalingPlanTimeZone string = 'W. Europe Standard Time'
param weekdaysScheduleName string = 'Demo weekdays'
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekdaysSchedulepeakLoadBalancingAlgorithm string = 'BreadthFirst'
param weekdaysSchedulepeakStartTimeHour int = 9
param weekdaysSchedulepeakStartTimeMinute int = 0
param weekdaysSchedulerampDownCapacityThresholdPct int = 10
param weekdaysSchedulerampDownForceLogoffUsers bool = false
param weekdaysSchedulerampDownMinimumHostsPct int = 10
param weekdaysSchedulerampDownStartTimeHour int = 18
param weekdaysSchedulerampDownStartTimeMinute int = 0
@allowed([
'ZeroSessions'
'ZeroActiveSessions'
])
param weekdaysSchedulerampDownStopHostsWhen string = 'ZeroSessions'
param weekdaysSchedulerampUpCapacityThresholdPct int = 60
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekdaysSchedulerampUpLoadBalancingAlgorithm string = 'DepthFirst'
param weekdaysSchedulerampUpMinimumHostsPct int = 20
param weekdaysSchedulerampUpStartTimeHour int = 8
param weekdaysSchedulerampUpStartTimeMinute int = 0
param weekdaysScheduleoffPeakStartTimeHour int = 20
param weekdaysScheduleoffPeakStartTimeMinute int = 0
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekdaysSchedulerampDownLoadBalancingAlgorithm string = 'DepthFirst'
param weekdaysrampDownWaitTimeMinutes int = 30
param weekdaysrampDownNotificationMessage string = 'You will be logged off in 30 min. Make sure to save your work.'
param weekendsScheduleName string = 'Demo weekends'
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekendsSchedulepeakLoadBalancingAlgorithm string = 'BreadthFirst'
param weekendsSchedulepeakStartTimeHour int = 9
param weekendsSchedulepeakStartTimeMinute int = 0
param weekendsSchedulerampDownCapacityThresholdPct int = 10
param weekendsSchedulerampDownForceLogoffUsers bool = false
param weekendsSchedulerampDownMinimumHostsPct int = 10
param weekendsSchedulerampDownStartTimeHour int = 18
param weekendsSchedulerampDownStartTimeMinute int = 0
@allowed([
'ZeroSessions'
'ZeroActiveSessions'
])
param weekendsSchedulerampDownStopHostsWhen string = 'ZeroSessions'
param weekendsSchedulerampUpCapacityThresholdPct int = 60
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekendsSchedulerampUpLoadBalancingAlgorithm string = 'DepthFirst'
param weekendsSchedulerampUpMinimumHostsPct int = 20
param weekendsSchedulerampUpStartTimeHour int = 8
param weekendsSchedulerampUpStartTimeMinute int = 0
param weekendsScheduleoffPeakStartTimeHour int = 20
param weekendsScheduleoffPeakStartTimeMinute int = 0
@allowed([
'BreadthFirst'
'DepthFirst'
])
param weekendsSchedulerampDownLoadBalancingAlgorithm string = 'DepthFirst'
param weekendsrampDownWaitTimeMinutes int = 30
param weekendsrampDownNotificationMessage string = 'You will be logged off in 30 min. Make sure to save your work.'
var AVDbackplanes = [
{
hostpoolName: hostpoolName
hostpoolFriendlyName: hostpoolFriendlyName
appgroupName: appgroupName
appgroupDesktopFriendlyName: appgroupDesktopFriendlyName
workspaceName: workspaceName
workspaceNameFriendlyName: workspaceFriendlyName
preferredAppGroupType: preferredAppGroupType
AVDbackplanelocation: AVDbackplanelocation
hostPoolType: hostPoolType
enableValiatioMode: false
loadBalancerType: loadBalancerType
createRemoteAppHostpool: true
startVMOnConnect: true
}
]
//Concat the PoolArmPath required by the scalingplan
var scalingPlanhostPoolArmPath = '${subscription().id}/resourcegroups/${rgAVD.name}/providers/Microsoft.DesktopVirtualization/hostpools/${hostpoolName}'
//Create Resource Groups
resource rgnw 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${resourceGroupPrefix}NETWORK${resourceGroupPostfix}'
location: 'westeurope'
}
resource rgAVD 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${resourceGroupPrefix}BACKPLANE${resourceGroupPostfix}'
location: 'westeurope'
}
resource rgmon 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${resourceGroupPrefix}MONITORING${resourceGroupPostfix}'
location: 'westeurope'
}
resource rgAVDhost 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${resourceGroupPrefix}HOSTS${resourceGroupPostfix}'
location: 'westeurope'
}
resource rdScaling 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: '${resourceGroupPrefix}SCALING${resourceGroupPostfix}'
location: 'westeurope'
}
@description('Create AVD Prod backplane objects')
module AVDbackplaneprod 'br/CoreModules:module-avd-backplane:v1' = [for AVDbackplane in AVDbackplanes: {
name: '${AVDbackplane.hostpoolName}-deploy'
scope: rgAVD
params: {
hostpoolName: AVDbackplane.hostpoolName
hostpoolFriendlyName: AVDbackplane.hostpoolFriendlyName
appgroupName: AVDbackplane.appgroupName
appgroupDesktopFriendlyName: AVDbackplane.appgroupDesktopFriendlyName
workspaceName: AVDbackplane.workspaceName
workspaceNameFriendlyName: AVDbackplane.workspaceNameFriendlyName
preferredAppGroupType: AVDbackplane.preferredAppGroupType
AVDbackplanelocation: AVDbackplane.AVDbackplanelocation
hostPoolType: AVDbackplane.hostPoolType
enableValiatioMode: AVDbackplane.enableValiatioMode
loadBalancerType: AVDbackplane.loadBalancerType
startVMOnConnect: AVDbackplane.startVMOnConnect
}
}]
@description('Create AVD NetwertandSubnet')
module AVDnetwork 'br/CoreModules:module-avd-network:v1' = {
name: 'AVDnetwork'
scope: rgnw
params: {
vnetLocation: rgnw.location
vnetName: vnetName
vnetaddressPrefix: vnetaddressPrefix
dnsServer: dnsServer
subnet1Prefix: subnetPrefix
subnet1Name: subnetName
createPeering: createPeering
remoteVnetName: remoteVnetName
remoteVnetRg: remoteVnetRg
vNetVMResourceGroup: rgnw.name
}
}
@description('Create Azure Log Analytics Workspace')
module AVDla 'br/CoreModules:module-avdlog-analytics:v1' = {
name: 'AVDla'
scope: rgmon
params: {
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
logAnalyticslocation: rgmon.location
logAnalyticsWorkspaceSku: logAnalyticsWorkspaceSku
}
}
@description('Config log analytics for all AVD control plane resources')
module AVDMon 'br/CoreModules:module-avd-monitor:v1' = {
name: 'AVDMon'
scope: rgmon
params: {
appGroupName: appgroupName
AVDBackplaneResourceGroup: rgAVD.name
hostpoolName: hostpoolName
logAnalyticsWorkspaceID: AVDla.outputs.logAnalyticsWorkspaceResourceID
workspaceName: workspaceName
}
}
@description('Create the AVD Session Host with GPU support')
module AVDSessionHost 'br/CoreModules:module-avd-sessionhost:v1' = {
scope: rgAVDhost
name: 'AVDSessionHost'
params: {
domainJoinPassword: secretValueDomainJoin
domainJoinUPN: domainJoinUSer
localAdminPassword: secretValueLocalAdminPassword
registrationKey: AVDbackplaneprod[0].outputs.hpkey
virtualMachineSizeWVD: vmSize
existingVnetName: vnetName
existingSubnetName: subnetName
existingVnetResourceGroupName: rgnw.name
hostNamePrefixWVD: vmNameprefix
numberOfInstancesWVD: 1
availabilitySetName: avSetName
ouLocationWVDSessionHost: ouLocationWVDSessionHost
adDomainName: adDomainName
gpuType: gpuType
}
dependsOn: [
AVDbackplaneprod
]
}
module AVDScaling 'br/CoreModules:module-avd-scaling-plan:v1' = {
scope: rdScaling
name: 'rdScaling'
params: {
scalingPlanDescription: scalingPlanDescription
scalingPlanExclusionTag: scalingPlanExclusionTag
scalingPlanFriendlyName: scalingPlanFriendlyName
scalingPlanHostPoolType: scalingPlanHostPoolType
scalingPlanLocation: scalingPlanLocation
scalingPlanName: scalingPlanName
scalingPlanTimeZone: scalingPlanTimeZone
scalingPlanhostPoolArmPath: scalingPlanhostPoolArmPath
scalingPlanEnabled: true
weekdaysrampDownNotificationMessage: weekdaysrampDownNotificationMessage
weekdaysrampDownWaitTimeMinutes: weekdaysrampDownWaitTimeMinutes
weekdaysScheduleName: weekdaysScheduleName
weekdaysScheduleoffPeakStartTimeHour: weekdaysScheduleoffPeakStartTimeHour
weekdaysScheduleoffPeakStartTimeMinute: weekdaysScheduleoffPeakStartTimeMinute
weekdaysSchedulepeakLoadBalancingAlgorithm: weekdaysSchedulepeakLoadBalancingAlgorithm
weekdaysSchedulepeakStartTimeHour: weekdaysSchedulepeakStartTimeHour
weekdaysSchedulepeakStartTimeMinute: weekdaysSchedulepeakStartTimeMinute
weekdaysSchedulerampDownCapacityThresholdPct: weekdaysSchedulerampDownCapacityThresholdPct
weekdaysSchedulerampDownForceLogoffUsers: weekdaysSchedulerampDownForceLogoffUsers
weekdaysSchedulerampDownLoadBalancingAlgorithm: weekdaysSchedulerampDownLoadBalancingAlgorithm
weekdaysSchedulerampDownMinimumHostsPct: weekdaysSchedulerampDownMinimumHostsPct
weekdaysSchedulerampDownStartTimeHour: weekdaysSchedulerampDownStartTimeHour
weekdaysSchedulerampDownStartTimeMinute: weekdaysSchedulerampDownStartTimeMinute
weekdaysSchedulerampDownStopHostsWhen: weekdaysSchedulerampDownStopHostsWhen
weekdaysSchedulerampUpCapacityThresholdPct: weekdaysSchedulerampUpCapacityThresholdPct
weekdaysSchedulerampUpLoadBalancingAlgorithm: weekdaysSchedulerampUpLoadBalancingAlgorithm
weekdaysSchedulerampUpMinimumHostsPct: weekdaysSchedulerampUpMinimumHostsPct
weekdaysSchedulerampUpStartTimeHour: weekdaysSchedulerampUpStartTimeHour
weekdaysSchedulerampUpStartTimeMinute: weekdaysSchedulerampUpStartTimeMinute
weekendsrampDownNotificationMessage: weekendsrampDownNotificationMessage
weekendsrampDownWaitTimeMinutes: weekendsrampDownWaitTimeMinutes
weekendsScheduleName: weekendsScheduleName
weekendsScheduleoffPeakStartTimeHour: weekendsScheduleoffPeakStartTimeHour
weekendsScheduleoffPeakStartTimeMinute: weekendsScheduleoffPeakStartTimeMinute
weekendsSchedulepeakLoadBalancingAlgorithm: weekendsSchedulepeakLoadBalancingAlgorithm
weekendsSchedulepeakStartTimeHour: weekendsSchedulepeakStartTimeHour
weekendsSchedulepeakStartTimeMinute: weekendsSchedulepeakStartTimeMinute
weekendsSchedulerampDownCapacityThresholdPct: weekendsSchedulerampDownCapacityThresholdPct
weekendsSchedulerampDownForceLogoffUsers: weekendsSchedulerampDownForceLogoffUsers
weekendsSchedulerampDownLoadBalancingAlgorithm: weekendsSchedulerampDownLoadBalancingAlgorithm
weekendsSchedulerampDownMinimumHostsPct: weekendsSchedulerampDownMinimumHostsPct
weekendsSchedulerampDownStartTimeHour: weekendsSchedulerampDownStartTimeHour
weekendsSchedulerampDownStartTimeMinute: weekendsSchedulerampDownStartTimeMinute
weekendsSchedulerampDownStopHostsWhen: weekendsSchedulerampDownStopHostsWhen
weekendsSchedulerampUpCapacityThresholdPct: weekendsSchedulerampUpCapacityThresholdPct
weekendsSchedulerampUpLoadBalancingAlgorithm: weekendsSchedulerampUpLoadBalancingAlgorithm
weekendsSchedulerampUpMinimumHostsPct: weekendsSchedulerampUpMinimumHostsPct
weekendsSchedulerampUpStartTimeHour: weekendsSchedulerampUpStartTimeHour
weekendsSchedulerampUpStartTimeMinute: weekendsSchedulerampUpStartTimeMinute
}
dependsOn: [
AVDbackplaneprod
]
}