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.

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