JohannesSoderberg

ServerTemplate.json

Jan 13th, 2020
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 7.12 KB | None | 0 0
  1. {
  2.     "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  3.     "contentVersion": "1.0.0.0",
  4.     "parameters": {
  5.         "location": {
  6.             "type": "string",
  7.             "defaultValue": "[resourceGroup().location]"
  8.         },
  9.         "networkInterfaceName": {
  10.             "type": "string"
  11.         },
  12.          "projectName": {
  13.             "type": "string"
  14.         },
  15.         "networkSecurityGroupName": {
  16.             "type": "string",
  17.             "defaultValue": "[concat(parameters('projectName'), 'Nsg')]"
  18.         },
  19.         "networkSecurityGroupRules": {
  20.             "type": "array",
  21.             "defaultValue":
  22.             [
  23.             {
  24.                 "name": "SSH",
  25.                 "properties": {
  26.                     "priority": 300,
  27.                     "protocol": "TCP",
  28.                     "access": "Allow",
  29.                     "direction": "Inbound",
  30.                     "sourceAddressPrefix": "*",
  31.                     "sourcePortRange": "*",
  32.                     "destinationAddressPrefix": "*",
  33.                     "destinationPortRange": "22"
  34.                 }
  35.             }
  36.             ]
  37.         },
  38.         "subnetName": {
  39.             "type": "string",
  40.              "defaultValue": "default"
  41.         },
  42.         "virtualNetworkName": {
  43.             "type": "string",
  44.             "defaultValue": "[concat(resourceGroup().name, '-vnet')]"
  45.         },
  46.         "addressPrefixes": {
  47.             "type": "array",
  48.             "defaultValue": [
  49.                "10.0.0.0/24"
  50.             ]
  51.         },
  52.         "subnets": {
  53.             "type": "array",
  54.             "defaultValue": [
  55.                 {
  56.                     "name": "default",
  57.                     "properties": {
  58.                         "addressPrefix": "10.0.0.0/24"
  59.                     }
  60.                 }
  61.             ]
  62.         },
  63.         "publicIpAddressName": {
  64.             "type": "string"
  65.         },
  66.         "virtualMachineName": {
  67.             "type": "string"
  68.         },
  69.         "osDiskType": {
  70.             "type": "string",
  71.             "defaultValue": "Standard_LRS"
  72.         },
  73.         "virtualMachineSize": {
  74.             "type": "string",
  75.             "defaultValue": "Standard_B1ls"
  76.         },
  77.         "adminUsername": {
  78.             "type": "string"
  79.         },
  80.         "adminPassword": {
  81.             "type": "securestring"
  82.         }
  83.  
  84.     },
  85.     "variables": {
  86.         "nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroupName'))]",
  87.         "vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
  88.         "subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
  89.     },
  90.     "resources": [
  91.         {
  92.             "name": "[parameters('networkInterfaceName')]",
  93.             "type": "Microsoft.Network/networkInterfaces",
  94.             "apiVersion": "2019-07-01",
  95.             "location": "[parameters('location')]",
  96.             "dependsOn": [
  97.                 "[concat('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
  98.                 "[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
  99.                 "[concat('Microsoft.Network/publicIpAddresses/', parameters('publicIpAddressName'))]"
  100.             ],
  101.             "properties": {
  102.                 "ipConfigurations": [
  103.                     {
  104.                         "name": "ipconfig1",
  105.                         "properties": {
  106.                             "subnet": {
  107.                                 "id": "[variables('subnetRef')]"
  108.                             },
  109.                             "privateIPAllocationMethod": "Dynamic",
  110.                             "publicIpAddress": {
  111.                                 "id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', parameters('publicIpAddressName'))]"
  112.                             }
  113.                         }
  114.                     }
  115.                 ],
  116.                 "networkSecurityGroup": {
  117.                     "id": "[variables('nsgId')]"
  118.                 }
  119.             }
  120.         },
  121.         {
  122.             "name": "[parameters('networkSecurityGroupName')]",
  123.             "type": "Microsoft.Network/networkSecurityGroups",
  124.             "apiVersion": "2019-02-01",
  125.             "location": "[parameters('location')]",
  126.             "properties": {
  127.                 "securityRules": "[parameters('networkSecurityGroupRules')]"
  128.             }
  129.         },
  130.         {
  131.             "name": "[parameters('virtualNetworkName')]",
  132.             "type": "Microsoft.Network/virtualNetworks",
  133.             "apiVersion": "2019-04-01",
  134.             "location": "[parameters('location')]",
  135.             "properties": {
  136.                 "addressSpace": {
  137.                     "addressPrefixes": "[parameters('addressPrefixes')]"
  138.                 },
  139.                 "subnets": "[parameters('subnets')]"
  140.             }
  141.         },
  142.         {
  143.             "name": "[parameters('publicIpAddressName')]",
  144.             "type": "Microsoft.Network/publicIpAddresses",
  145.             "apiVersion": "2019-02-01",
  146.             "location": "[parameters('location')]",
  147.             "properties": {
  148.                 "publicIpAllocationMethod": "Dynamic"
  149.             },
  150.             "sku": {
  151.                 "name": "Basic"
  152.             }
  153.         },
  154.         {
  155.             "name": "[parameters('virtualMachineName')]",
  156.             "type": "Microsoft.Compute/virtualMachines",
  157.             "apiVersion": "2019-07-01",
  158.             "location": "[parameters('location')]",
  159.             "dependsOn": [
  160.                 "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
  161.             ],
  162.             "properties": {
  163.                 "hardwareProfile": {
  164.                     "vmSize": "[parameters('virtualMachineSize')]"
  165.                 },
  166.                 "storageProfile": {
  167.                     "osDisk": {
  168.                         "createOption": "fromImage",
  169.                         "managedDisk": {
  170.                             "storageAccountType": "[parameters('osDiskType')]"
  171.                         }
  172.                     },
  173.                     "imageReference": {
  174.                         "publisher": "Canonical",
  175.                         "offer": "UbuntuServer",
  176.                         "sku": "18.04-LTS",
  177.                         "version": "latest"
  178.                     }
  179.                 },
  180.                 "networkProfile": {
  181.                     "networkInterfaces": [
  182.                         {
  183.                             "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
  184.                         }
  185.                     ]
  186.                 },
  187.                 "osProfile": {
  188.                     "computerName": "[parameters('virtualMachineName')]",
  189.                     "adminUsername": "[parameters('adminUsername')]",
  190.                     "adminPassword": "[parameters('adminPassword')]"
  191.                 }
  192.             },
  193.             "identity": {
  194.                 "type": "systemAssigned"
  195.             }
  196.         }
  197.     ]
  198. }
Advertisement
Add Comment
Please, Sign In to add comment