cdn-django/azuredeploy.json

raw link view readme
1
2 {
3 "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
4 "contentVersion": "1.0.0.0",
5 "parameters": {
6 "admin-username": {
7 "type": "string"
8 },
9 "ssh-public-key": {
10 "type": "string"
11 }
12 },
13 "variables": {
14 "ssh-keypath": "[concat('/home/', parameters('admin-username'), '/.ssh/authorized_keys')]",
15 "unique": "[substring(uniquestring(resourceGroup().name), 0, 5)]",
16 "unique-prefix": "[concat(resourceGroup().name, variables('unique'))]",
17 "storage-name": "[variables('unique-prefix')]",
18 "cdn-storage-name": "[concat(variables('unique-prefix'), 'cdn')]",
19 "cdn-profile-name": "[concat(variables('unique-prefix'), '-cdn')]",
20 "cdn-asset-endpoint": "[concat(variables('cdn-profile-name'), '-asset', variables('unique'))]",
21 "cdn-name": "[concat(resourceGroup().name, '-cdn')]",
22 "vnet-name": "[concat(resourceGroup().name, '-vnet')]",
23 "ip-prefix": "[concat(resourceGroup().name, '-ip-')]",
24 "nsg-prefix": "[concat(resourceGroup().name, '-nsg-')]",
25 "vm-prefix": "[concat(resourceGroup().name, '-vm-')]",
26 "nic-prefix": "[concat(resourceGroup().name, '-nic-')]",
27 "names": [
28 "alpha",
29 "beta",
30 "gamma",
31 "delta",
32 "epsilon",
33 "zeta",
34 "eta",
35 "theta",
36 "iota",
37 "kappa",
38 "lambda",
39 "mu",
40 "nu",
41 "xi",
42 "omicron",
43 "pi",
44 "rho",
45 "sigma",
46 "tau",
47 "upsilon",
48 "phi",
49 "chi",
50 "psi",
51 "omega"
52 ],
53 "vm-size": "Standard_DS1_v2",
54 "vnet-address-space": "10.16.0.0/12",
55 "vnet-subnet01-octet": 17
56 },
57 "resources": [
58 {
59 "comments": "",
60 "type": "Microsoft.Network/publicIPAddresses",
61 "name": "[concat(variables('ip-prefix'), variables('names')[0])]",
62 "apiVersion": "2017-03-01",
63 "location": "[resourceGroup().location]",
64 "properties": {
65 "publicIPAllocationMethod": "Dynamic",
66 "idleTimeoutInMinutes": 4,
67 "dnsSettings": {
68 "domainNameLabel": "[concat(variables('unique-prefix'), '-', variables('names')[0])]"
69 }
70 },
71 "resources": [],
72 "dependsOn": []
73 },
74 {
75 "comments": "",
76 "type": "Microsoft.Compute/virtualMachines",
77 "name": "[concat(variables('vm-prefix'), variables('names')[0])]",
78 "apiVersion": "2016-04-30-preview",
79 "location": "[resourceGroup().location]",
80 "properties": {
81 "hardwareProfile": {
82 "vmSize": "[variables('vm-size')]"
83 },
84 "storageProfile": {
85 "imageReference": {
86 "publisher": "OpenLogic",
87 "offer": "CentOS",
88 "sku": "7.2",
89 "version": "latest"
90 },
91 "osDisk": {
92 "name": "[concat(variables('vm-prefix'), variables('names')[0], '-boot')]",
93 "createOption": "FromImage",
94 "vhd": {
95 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[0], '-boot.vhd')]"
96 },
97 "caching": "ReadWrite"
98 },
99 "dataDisks": [
100 {
101 "name": "[concat(variables('vm-prefix'), variables('names')[0], '-disk01')]",
102 "diskSizeGB": 127,
103 "lun": 0,
104 "vhd": {
105 "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storage-name')), '2015-06-15').primaryEndpoints.blob, 'vhds/', variables('names')[0], '-data01.vhd')]"
106 },
107 "createOption": "Empty"
108 }
109 ]
110 },
111 "osProfile": {
112 "computerName": "[concat(variables('vm-prefix'), variables('names')[0])]",
113 "adminUsername": "[parameters('admin-username')]",
114 "linuxConfiguration": {
115 "disablePasswordAuthentication": true,
116 "ssh": {
117 "publicKeys": [
118 {
119 "path": "[variables('ssh-keypath')]",
120 "keyData": "[parameters('ssh-public-key')]"
121 }
122 ]
123 }
124 }
125 },
126 "networkProfile": {
127 "networkInterfaces": [
128 {
129 "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nic-prefix'), variables('names')[0]))]"
130 }
131 ]
132 }
133 },
134 "resources": [],
135 "dependsOn": [
136 "[resourceId('Microsoft.Storage/storageAccounts', variables('storage-name'))]",
137 "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nic-prefix'), variables('names')[0]))]"
138 ]
139 },
140 {
141 "type": "Microsoft.Compute/virtualMachines/extensions",
142 "name": "[concat(variables('vm-prefix'), variables('names')[0], '/script')]",
143 "apiVersion": "2015-05-01-preview",
144 "location": "[resourceGroup().location]",
145 "dependsOn": [
146 "[concat(variables('vm-prefix'), variables('names')[0])]"
147 ],
148 "properties": {
149 "publisher": "Microsoft.Azure.Extensions",
150 "type": "CustomScript",
151 "typeHandlerVersion": "2.0",
152 "autoUpgradeMinorVersion": true,
153 "settings": {
154 "fileUris": [
155 "https://linux.azure.david.betz.space/raw/cdn-django/install.sh"
156 ],
157 "commandToExecute": "[concat('sh install.sh ', variables('cdn-storage-name'), ' ', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('cdn-storage-name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value, ' ', variables('unique-prefix'), '-', variables('names')[0], '.', resourceGroup().location, '.cloudapp.azure.com ', variables('cdn-asset-endpoint'))]"
158 }
159 }
160 },
161 {
162 "comments": "",
163 "type": "Microsoft.Network/networkInterfaces",
164 "name": "[concat(variables('nic-prefix'), variables('names')[0])]",
165 "apiVersion": "2017-03-01",
166 "location": "[resourceGroup().location]",
167 "properties": {
168 "ipConfigurations": [
169 {
170 "name": "ifconfig1",
171 "properties": {
172 "privateIPAllocationMethod": "Dynamic",
173 "publicIPAddress": {
174 "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[0]))]"
175 },
176 "subnet": {
177 "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name')), '/subnets/subnet01')]"
178 }
179 }
180 }
181 ],
182 "dnsSettings": {
183 "dnsServers": []
184 },
185 "enableIPForwarding": false,
186 "networkSecurityGroup": {
187 "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
188 }
189 },
190 "resources": [],
191 "dependsOn": [
192 "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('ip-prefix'), variables('names')[0]))]",
193 "[resourceId('Microsoft.Network/virtualNetworks', variables('vnet-name'))]",
194 "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('nsg-prefix'), variables('names')[0]))]"
195 ]
196 },
197 {
198 "comments": "",
199 "type": "Microsoft.Network/virtualNetworks",
200 "name": "[variables('vnet-name')]",
201 "apiVersion": "2017-03-01",
202 "location": "[resourceGroup().location]",
203 "properties": {
204 "addressSpace": {
205 "addressPrefixes": [
206 "[variables('vnet-address-space')]"
207 ]
208 },
209 "subnets": [
210 {
211 "name": "subnet01",
212 "properties": {
213 "addressPrefix": "[concat('10.', variables('vnet-subnet01-octet'), '.0.0/16')]"
214 }
215 }
216 ]
217 },
218 "resources": [],
219 "dependsOn": []
220 },
221 {
222 "comments": "",
223 "type": "Microsoft.Network/networkSecurityGroups",
224 "name": "[concat(variables('nsg-prefix'), variables('names')[0])]",
225 "apiVersion": "2017-03-01",
226 "location": "[resourceGroup().location]",
227 "properties": {
228 "securityRules": [
229 {
230 "name": "default-allow-ssh",
231 "properties": {
232 "protocol": "Tcp",
233 "sourcePortRange": "*",
234 "destinationPortRange": "22",
235 "sourceAddressPrefix": "*",
236 "destinationAddressPrefix": "*",
237 "access": "Allow",
238 "priority": 1000,
239 "direction": "Inbound"
240 }
241 },
242 {
243 "name": "http",
244 "properties": {
245 "protocol": "Tcp",
246 "sourcePortRange": "*",
247 "destinationPortRange": "80",
248 "sourceAddressPrefix": "*",
249 "destinationAddressPrefix": "*",
250 "access": "Allow",
251 "priority": 1100,
252 "direction": "Inbound"
253 }
254 },
255 {
256 "name": "https",
257 "properties": {
258 "protocol": "Tcp",
259 "sourcePortRange": "*",
260 "destinationPortRange": "443",
261 "sourceAddressPrefix": "*",
262 "destinationAddressPrefix": "*",
263 "access": "Allow",
264 "priority": 1200,
265 "direction": "Inbound"
266 }
267 }
268 ]
269 },
270 "resources": [],
271 "dependsOn": []
272 },
273 {
274 "comments": "",
275 "type": "Microsoft.Storage/storageAccounts",
276 "sku": {
277 "name": "Standard_LRS",
278 "tier": "Standard"
279 },
280 "kind": "Storage",
281 "name": "[variables('storage-name')]",
282 "apiVersion": "2016-01-01",
283 "location": "[resourceGroup().location]",
284 "tags": {},
285 "properties": {},
286 "resources": [],
287 "dependsOn": []
288 },
289 {
290 "comments": "cdn",
291 "type": "Microsoft.Storage/storageAccounts",
292 "name": "[concat(variables('cdn-storage-name'))]",
293 "apiVersion": "2016-01-01",
294 "location": "[resourceGroup().location]",
295 "sku": {
296 "name": "Standard_LRS",
297 "tier": "Standard"
298 },
299 "kind": "BlobStorage",
300 "properties": {
301 "accessTier": "Hot"
302 },
303 "tags": {},
304 "resources": [],
305 "dependsOn": []
306 },
307 {
308 "comments": "",
309 "type": "Microsoft.Cdn/profiles",
310 "sku": {
311 "name": "Standard_Akamai"
312 },
313 "name": "[variables('cdn-profile-name')]",
314 "apiVersion": "2016-04-02",
315 "location": "[resourceGroup().location]",
316 "tags": {},
317 "properties": {},
318 "resources": [],
319 "dependsOn": []
320 },
321 {
322 "comments": "",
323 "type": "Microsoft.Cdn/profiles/endpoints",
324 "name": "[concat(variables('cdn-profile-name'), '/', variables('cdn-asset-endpoint'))]",
325 "apiVersion": "2016-04-02",
326 "location": "[resourceGroup().location]",
327 "tags": {},
328 "properties": {
329 "originHostHeader": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('cdn-storage-name')),'2016-01-01').primaryEndpoints.blob,'https://',''),'/','')]",
330 "isHttpAllowed": true,
331 "isHttpsAllowed": true,
332 "queryStringCachingBehavior": "IgnoreQueryString",
333 "contentTypesToCompress": [
334 "text/plain",
335 "text/html",
336 "text/css",
337 "application/javascript",
338 "application/x-javascript",
339 "text/javascript",
340 "image/svg+xml"
341 ],
342 "originPath": null,
343 "isCompressionEnabled": true,
344 "origins": [
345 {
346 "name": "origin01",
347 "properties": {
348 "hostName": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('cdn-storage-name')),'2016-01-01').primaryEndpoints.blob,'https://',''),'/','')]"
349 }
350 }
351 ]
352 },
353 "resources": [],
354 "dependsOn": [
355 "[resourceId('Microsoft.Cdn/profiles', variables('cdn-profile-name'))]",
356 "[resourceId('Microsoft.Storage/storageAccounts', variables('cdn-storage-name'))]"
357 ]
358 }
359 ],
360 "outputs": {
361 "sshCommand": {
362 "type": "string",
363 "value": "[concat('ssh ', variables('unique-prefix'), '-', variables('names')[0], '.', resourceGroup().location, '.cloudapp.azure.com')]"
364 }
365 }
366 }
367
368
369
370