cdn-django/azuredeploy.json

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