-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathadd-wvdhosttohostpoolSpring.bicep
176 lines (167 loc) · 5.29 KB
/
add-wvdhosttohostpoolSpring.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
param adDomainName string
param assetLocation string = 'https://raw.githubusercontent.com/fberson/wvd/master/'
param existingAvailabilitySetName string
param domainJoinUPN string
param existingSharedImageGalleryName string
param existingSharedImageGalleryDefinitionName string
param existingSharedImageGalleryVersionName string = 'latest'
param existingSharedImageGalleryResourceGroup string
param existingSubnetName string
param existingVnetName string
param existingVnetResourceGroupName string
param hostNamePrefixWVD string
param numberOfInstancesWVD int = 10
param ouLocationWVDSessionHost string
param sequenceStartNumberWVDHost int = 1
param virtualMachineSizeWVD string = 'Standard_D4s_v3'
param configureLogAnalyticsWorkspace bool = false
@secure()
param localAdminPassword string
@secure()
param domainJoinPassword string
@secure()
param registrationKey string
var domainJoinOptions = 3
var networkSubnetId = '${networkVnetId}/subnets/${existingSubnetName}'
var networkVnetId = resourceId(existingVnetResourceGroupName, 'Microsoft.Network/virtualNetworks', existingVnetName)
var storage = {
type: 'StandardSSD_LRS'
}
var virtualmachineosdisk = {
cacheOption: 'ReadWrite'
createOption: 'FromImage'
diskName: 'OS'
}
var vmTimeZone = 'W. Europe Standard Time'
var networkAdapterIPConfigName = 'ipconfig'
var networkAdapterNamePostFix = '-nic'
var networkAdapterIPAllocationMethod = 'Dynamic'
var imageResourceId = resourceId(existingSharedImageGalleryResourceGroup, 'Microsoft.Compute/galleries/images/versions', existingSharedImageGalleryName, existingSharedImageGalleryDefinitionName, existingSharedImageGalleryVersionName)
var configurationScriptWVD = 'Add-WVDHostToHostpoolSpringV2.ps1'
resource avset 'Microsoft.Compute/availabilitySets@2020-06-01' = {
name: existingAvailabilitySetName
location: resourceGroup().location
tags: {
displayName: 'WVD AvailabilitySet'
}
properties: {
platformUpdateDomainCount: 2
platformFaultDomainCount: 2
}
sku: {
name: 'Aligned'
}
}
resource nic 'Microsoft.Network/networkInterfaces@2020-06-01' = [for i in range(0, numberOfInstancesWVD): {
name: '${hostNamePrefixWVD}-${(i+sequenceStartNumberWVDHost)}${networkAdapterNamePostFix}'
tags: {
displayName: 'WVD Session Host Network interfaces'
}
location: resourceGroup().location
properties: {
ipConfigurations: [
{
name: networkAdapterIPConfigName
properties: {
privateIPAllocationMethod: networkAdapterIPAllocationMethod
subnet: {
id: networkSubnetId
}
}
}
]
}
}]
resource vm 'Microsoft.Compute/virtualMachines@2020-06-01' = [for i in range(0, numberOfInstancesWVD): {
name: '${hostNamePrefixWVD}-${(i+sequenceStartNumberWVDHost)}'
tags: {
displayName: 'WVD Session Host Virtual Machines'
}
location: resourceGroup().location
properties: {
licenseType: 'Windows_Client'
hardwareProfile: {
vmSize: virtualMachineSizeWVD
}
availabilitySet: {
id: avset.id
}
osProfile: {
computerName: '${hostNamePrefixWVD}-${(i+sequenceStartNumberWVDHost)}'
adminUsername: '${hostNamePrefixWVD}-${(i+sequenceStartNumberWVDHost)}-adm'
adminPassword: localAdminPassword
windowsConfiguration: {
timeZone: vmTimeZone
}
}
storageProfile: {
osDisk: {
name: '${hostNamePrefixWVD}-${(i+sequenceStartNumberWVDHost)}-${virtualmachineosdisk.diskName}'
managedDisk: {
storageAccountType: storage.type
}
osType: 'Windows'
caching: virtualmachineosdisk.cacheOption
createOption: virtualmachineosdisk.createOption
}
imageReference: {
id: imageResourceId
}
dataDisks: []
}
networkProfile: {
networkInterfaces: [
{
id: nic[i].id
}
]
}
}
}]
resource wvd 'Microsoft.Compute/virtualMachines/extensions@2020-06-01' = [for i in range(0, numberOfInstancesWVD): {
name: '${vm[i].name}/wvd'
tags: {
displayName: 'PowerShell Extension'
}
location: resourceGroup().location
properties: {
publisher: 'Microsoft.Compute'
type: 'CustomScriptExtension'
typeHandlerVersion: '1.8'
autoUpgradeMinorVersion: true
settings: {
fileUris: [
'${assetLocation}${configurationScriptWVD}'
]
}
protectedSettings: {
commandToExecute: 'powershell.exe -ExecutionPolicy Unrestricted -File ${configurationScriptWVD} ${registrationKey} >> ${configurationScriptWVD}.log 2>&1'
}
}
}]
resource domainjoin 'Microsoft.Compute/virtualMachines/extensions@2020-06-01' = [for i in range(0, numberOfInstancesWVD): {
name: '${vm[i].name}/domainjoin'
tags: {
displayName: 'DomainJoin Extension'
}
location: resourceGroup().location
properties: {
publisher: 'Microsoft.Compute'
type: 'JsonADDomainExtension'
typeHandlerVersion: '1.3'
autoUpgradeMinorVersion: true
settings: {
Name: adDomainName
OUPath: ouLocationWVDSessionHost
User: domainJoinUPN
Restart: true
Options: domainJoinOptions
}
protectedSettings: {
Password: domainJoinPassword
}
}
dependsOn: [
wvd[i]
]
}]