-
Notifications
You must be signed in to change notification settings - Fork 47
/
deployagents.json
202 lines (202 loc) · 7.37 KB
/
deployagents.json
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
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subnetId": {
"type": "string"
},
"adminPassword": {
"type": "securestring"
},
"adminUsername": {
"type": "string",
"defaultValue": "EnterpriseAdmin"
},
"domainName": {
"type": "string",
"defaultValue": "devnet.contoso.us"
},
"vmSize": {
"type": "string",
"allowedValues": [
"Standard_DS1_v2",
"Standard_DS2_v2",
"Standard_DS3_v2",
"Standard_DS4_v2",
"Standard_DS5_v2",
"Standard_DS11_v2",
"Standard_DS12_v2",
"Standard_DS13_v2",
"Standard_DS14_v2",
"Standard_DS15_v2"
],
"defaultValue": "Standard_DS2_v2"
},
"buildAgentVmInstanceCount": {
"type": "int",
"defaultValue": 2
},
"tfsServerUrl": {
"type": "string"
}
},
"variables": {
"baseUri": "[deployment().properties.templateLink.uri]",
"VSTSAgentInstallModuleURL": "[uri(variables('baseUri'), 'DSC/InstallVSTSAgent.ps1.zip')]",
"VSTSAgentInstallFunction": "InstallVSTSAgent.ps1\\VSTSAgentInstallDsc",
"agentDownloadUrl": "https://vstsagentpackage.azureedge.net/agent/2.127.0/vsts-agent-win-x64-2.127.0.zip",
"VSImagePublisher": "MicrosoftVisualStudio",
"VSImageOffer": "VisualStudio",
"VSImageSku": "VS-2017-Ent-Latest-WS2016",
"windowsVmTemplateURL": "[uri(variables('baseUri'),'../primitives/windowsvm.json')]",
"diagStorageAccountName": "[concat(uniquestring(resourceGroup().id), 'agvmdiag')]",
"HASetName": "AgentHASet",
"HASetId": "[if(greater(parameters('buildAgentVmInstanceCount'),1),resourceId('Microsoft.Compute/availabilitySets',variables('HASetName')),'')]",
"agentVMPrefix": "AGENT"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('diagStorageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
},
{
"name": "[variables('HASetName')]",
"type": "Microsoft.Compute/availabilitySets",
"location": "[resourceGroup().location]",
"apiVersion": "2017-03-30",
"condition": "[greater(parameters('buildAgentVmInstanceCount'),1)]",
"dependsOn": [],
"properties": {
"platformUpdateDomainCount": 2,
"platformFaultDomainCount": 2
},
"sku": {
"name": "Aligned"
}
},
{
"name": "[concat('agentVmDeploy', copyindex())]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"dependsOn": [
"[resourceId('Microsoft.Compute/availabilitySets', variables('HASetName'))]"
],
"copy": {
"name": "agentvmloop",
"count": "[parameters('buildAgentVmInstanceCount')]"
},
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('windowsVmTemplateURL')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"vmName": {
"value": "[concat(variables('agentVMPrefix'), copyindex())]"
},
"vmSize": {
"value": "[parameters('vmSize')]"
},
"subnetId": {
"value": "[parameters('subnetId')]"
},
"adminUsername": {
"value": "[parameters('adminUsername')]"
},
"adminPassword": {
"value": "[parameters('adminPassword')]"
},
"diagStorageAccountId": {
"value": "[resourceId('Microsoft.Storage/storageAccounts', variables('diagStorageAccountName'))]"
},
"availabilitySetId": {
"value": "[variables('HASetId')]"
},
"imagePublisher": {
"value": "[variables('VSImagePublisher')]"
},
"imageOffer": {
"value": "[variables('VSImageOffer')]"
},
"imageSku": {
"value": "[variables('VSImageSku')]"
}
}
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('agentVmPrefix'), copyindex(), '/joindomain')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Resources/deployments', concat('agentVmDeploy', copyindex()))]"
],
"copy": {
"name": "agentvmjoinloop",
"count": "[parameters('buildAgentVmInstanceCount')]"
},
"properties": {
"publisher": "Microsoft.Compute",
"type": "JsonADDomainExtension",
"typeHandlerVersion": "1.3",
"autoUpgradeMinorVersion": true,
"settings": {
"Name": "[parameters('domainName')]",
"OUPath": "",
"User": "[concat(parameters('domainName'), '\\', parameters('adminUserName'))]",
"Restart": "true",
"Options": "3"
},
"protectedSettings": {
"Password": "[parameters('adminPassword')]"
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('agentVmPrefix'), copyindex(), '/configureagent', copyindex())]",
"dependsOn": [
"[concat(resourceId('Microsoft.Compute/virtualMachines', concat(variables('agentVmPrefix'), copyindex())), '/extensions/joindomain')]"
],
"apiVersion": "2016-03-30",
"copy": {
"name": "agentconfigloop",
"count": "[parameters('buildAgentVmInstanceCount')]",
},
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.21",
"autoUpgradeMinorVersion": true,
"settings": {
"modulesURL": "[variables('VSTSAgentInstallModuleURL')]",
"configurationFunction": "[variables('VSTSAgentInstallFunction')]",
"properties": {
"domainName": "[parameters('domainName')]",
"adminCreds": {
"userName": "[parameters('adminUserName')]",
"password": "privateSettingsRef:adminPassword"
},
"TFSUrl": "[parameters('tfsServerUrl')]",
"VSTSAgentUrl": "[variables('agentDownloadUrl')]",
}
},
"protectedSettings": {
"items": {
"adminPassword": "[parameters('adminPassword')]"
}
}
}
}
]
}