You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
9.0 KiB

  1. {
  2. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  3. "contentVersion": "1.0.0.0",
  4. "parameters": {
  5. "VMName": {
  6. "type": "string",
  7. "metadata": {
  8. "description": "This name will also be used to prefix the network security group, storage, virtual network, network card, subnet and public IP address name."
  9. }
  10. },
  11. "adminUsername": {
  12. "type": "string",
  13. "metadata": {
  14. "description": "Username for the Virtual Machine."
  15. }
  16. },
  17. "adminPassword": {
  18. "type": "securestring",
  19. "metadata": {
  20. "description": "Password for the Virtual Machine."
  21. }
  22. },
  23. "dnsNameForPublicIP": {
  24. "type": "string",
  25. "metadata": {
  26. "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
  27. }
  28. },
  29. "newStorageAccountName": {
  30. "type": "string",
  31. "metadata": {
  32. "description": "Storage name for the Virtual Machine."
  33. }
  34. },
  35. "vmSize": {
  36. "type": "string",
  37. "defaultValue": "Standard_D1",
  38. "metadata": {
  39. "description": "VM Size"
  40. }
  41. }
  42. },
  43. "variables": {
  44. "windowsOSVersion": "2016-Datacenter",
  45. "imagePublisher": "MicrosoftWindowsServer",
  46. "imageOffer": "WindowsServer",
  47. "OSDiskName": "[concat(parameters('VMName'),'_osdisk')]",
  48. "nicName": "[concat(parameters('VMName'),'_nic')]",
  49. "addressPrefix": "10.0.0.0/16",
  50. "subnetName": "[concat(parameters('VMName'),'_subnet')]",
  51. "subnetPrefix": "10.0.0.0/24",
  52. "networkSecurityGroupName": "[concat(parameters('VMName'),'_nsg')]",
  53. "storageAccountType": "Standard_LRS",
  54. "publicIPAddressName": "[concat(parameters('VMName'),'_pubip')]",
  55. "publicIPAddressType": "Dynamic",
  56. "vmStorageAccountContainerName": "vhds",
  57. "apiVersion": "2015-05-01-preview",
  58. "virtualNetworkName": "[concat(parameters('VMName'),'_vnet')]",
  59. "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
  60. "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
  61. },
  62. "resources": [
  63. {
  64. "type": "Microsoft.Network/networkSecurityGroups",
  65. "name": "[variables('networkSecurityGroupName')]",
  66. "apiVersion": "[variables('apiVersion')]",
  67. "location": "[resourceGroup().location]",
  68. "properties": {
  69. "securityRules": [
  70. {
  71. "name": "HTTP",
  72. "properties": {
  73. "description": "HTTP",
  74. "protocol": "Tcp",
  75. "sourcePortRange": "*",
  76. "destinationPortRange": "80",
  77. "sourceAddressPrefix": "*",
  78. "destinationAddressPrefix": "*",
  79. "access": "Allow",
  80. "priority": 100,
  81. "direction": "Inbound"
  82. }
  83. },
  84. {
  85. "name": "RDP",
  86. "properties": {
  87. "description": "RDP",
  88. "protocol": "Tcp",
  89. "sourcePortRange": "*",
  90. "destinationPortRange": "3389",
  91. "sourceAddressPrefix": "*",
  92. "destinationAddressPrefix": "*",
  93. "access": "Allow",
  94. "priority": 200,
  95. "direction": "Inbound"
  96. }
  97. },
  98. {
  99. "name": "Docker",
  100. "properties": {
  101. "description": "Docker",
  102. "protocol": "Tcp",
  103. "sourcePortRange": "*",
  104. "destinationPortRange": "2375",
  105. "sourceAddressPrefix": "*",
  106. "destinationAddressPrefix": "*",
  107. "access": "Allow",
  108. "priority": 300,
  109. "direction": "Inbound"
  110. }
  111. }
  112. ]
  113. }
  114. },
  115. {
  116. "type": "Microsoft.Storage/storageAccounts",
  117. "name": "[parameters('newStorageAccountName')]",
  118. "apiVersion": "[variables('apiVersion')]",
  119. "location": "[resourceGroup().location]",
  120. "tags": {
  121. "displayName": "StorageAccount"
  122. },
  123. "properties": {
  124. "accountType": "[variables('storageAccountType')]"
  125. }
  126. },
  127. {
  128. "apiVersion": "[variables('apiVersion')]",
  129. "type": "Microsoft.Network/publicIPAddresses",
  130. "name": "[variables('publicIPAddressName')]",
  131. "location": "[resourceGroup().location]",
  132. "tags": {
  133. "displayName": "PublicIPAddress"
  134. },
  135. "properties": {
  136. "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
  137. "dnsSettings": {
  138. "domainNameLabel": "[tolower(parameters('dnsNameForPublicIP'))]"
  139. }
  140. }
  141. },
  142. {
  143. "apiVersion": "[variables('apiVersion')]",
  144. "type": "Microsoft.Network/virtualNetworks",
  145. "name": "[variables('virtualNetworkName')]",
  146. "location": "[resourceGroup().location]",
  147. "dependsOn": [
  148. "[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]"
  149. ],
  150. "tags": {
  151. "displayName": "VirtualNetwork"
  152. },
  153. "properties": {
  154. "addressSpace": {
  155. "addressPrefixes": [
  156. "[variables('addressPrefix')]"
  157. ]
  158. },
  159. "subnets": [
  160. {
  161. "name": "[variables('subnetName')]",
  162. "properties": {
  163. "addressPrefix": "[variables('subnetPrefix')]",
  164. "networkSecurityGroup": {
  165. "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
  166. }
  167. }
  168. }
  169. ]
  170. }
  171. },
  172. {
  173. "apiVersion": "[variables('apiVersion')]",
  174. "type": "Microsoft.Network/networkInterfaces",
  175. "name": "[variables('nicName')]",
  176. "location": "[resourceGroup().location]",
  177. "tags": {
  178. "displayName": "NetworkInterface"
  179. },
  180. "dependsOn": [
  181. "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
  182. "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
  183. ],
  184. "properties": {
  185. "ipConfigurations": [
  186. {
  187. "name": "ipconfig1",
  188. "properties": {
  189. "privateIPAllocationMethod": "Dynamic",
  190. "publicIPAddress": {
  191. "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
  192. },
  193. "subnet": {
  194. "id": "[variables('subnetRef')]"
  195. }
  196. }
  197. }
  198. ]
  199. }
  200. },
  201. {
  202. "apiVersion": "[variables('apiVersion')]",
  203. "type": "Microsoft.Compute/virtualMachines",
  204. "name": "[parameters('VMName')]",
  205. "location": "[resourceGroup().location]",
  206. "tags": {
  207. "displayName": "VirtualMachine"
  208. },
  209. "dependsOn": [
  210. "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
  211. "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
  212. ],
  213. "properties": {
  214. "hardwareProfile": {
  215. "vmSize": "[parameters('vmSize')]"
  216. },
  217. "osProfile": {
  218. "computername": "[parameters('VMName')]",
  219. "adminUsername": "[parameters('adminUsername')]",
  220. "adminPassword": "[parameters('adminPassword')]"
  221. },
  222. "storageProfile": {
  223. "imageReference": {
  224. "publisher": "[variables('imagePublisher')]",
  225. "offer": "[variables('imageOffer')]",
  226. "sku": "[variables('windowsOSVersion')]",
  227. "version": "latest"
  228. },
  229. "osDisk": {
  230. "name": "osdisk",
  231. "vhd": {
  232. "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
  233. },
  234. "caching": "ReadWrite",
  235. "createOption": "FromImage"
  236. }
  237. },
  238. "networkProfile": {
  239. "networkInterfaces": [
  240. {
  241. "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
  242. }
  243. ]
  244. }
  245. },
  246. "resources": [
  247. {
  248. "name": "containerConfiguration",
  249. "type": "extensions",
  250. "location": "[resourceGroup().location]",
  251. "apiVersion": "2015-06-15",
  252. "dependsOn": [
  253. "[concat('Microsoft.Compute/virtualMachines/', parameters('VMName'))]"
  254. ],
  255. "tags": {
  256. "displayName": "containerConfiguration"
  257. },
  258. "properties": {
  259. "publisher": "Microsoft.Compute",
  260. "type": "CustomScriptExtension",
  261. "typeHandlerVersion": "1.2",
  262. "autoUpgradeMinorVersion": true,
  263. "settings": {
  264. "fileUris": [
  265. "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/windows-server-containers-preview/azure-containers.ps1"
  266. ],
  267. "commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -File azure-containers.ps1 -adminuser ',parameters('adminUsername'))]"
  268. }
  269. }
  270. }
  271. ]
  272. }
  273. ]
  274. }