|
| 1 | +{ |
| 2 | + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", |
| 3 | + "contentVersion": "1.0.0.0", |
| 4 | + "parameters": { |
| 5 | + "adminUsername": { |
| 6 | + "type": "string", |
| 7 | + "metadata": { |
| 8 | + "description": "Name of existing VM Scale Set" |
| 9 | + } |
| 10 | + }, |
| 11 | + "adminPassword": { |
| 12 | + "type": "securestring", |
| 13 | + "metadata": { |
| 14 | + "description": "Number of desired VM instances" |
| 15 | + } |
| 16 | + } |
| 17 | + }, |
| 18 | + "variables": { |
| 19 | + "namingInfix": "existingvmss", |
| 20 | + "virtualNetworkName": "[concat(variables('namingInfix'), 'vnet')]", |
| 21 | + "publicIPAddressName": "[concat(variables('namingInfix'), 'pip')]", |
| 22 | + "subnetName": "[concat(variables('namingInfix'), 'subnet')]", |
| 23 | + "loadBalancerName": "[concat(variables('namingInfix'), 'lb')]", |
| 24 | + "natPoolName": "[concat(variables('namingInfix'), 'natpool')]", |
| 25 | + "bePoolName": "[concat(variables('namingInfix'), 'bepool')]" |
| 26 | + }, |
| 27 | + "resources": [{ |
| 28 | + "type": "Microsoft.Network/virtualNetworks", |
| 29 | + "name": "[variables('virtualNetworkName')]", |
| 30 | + "location": "[resourceGroup().location]", |
| 31 | + "apiVersion": "2016-03-30", |
| 32 | + "properties": { |
| 33 | + "addressSpace": { |
| 34 | + "addressPrefixes": [ |
| 35 | + "10.0.0.0/16" |
| 36 | + ] |
| 37 | + }, |
| 38 | + "subnets": [{ |
| 39 | + "name": "[variables('subnetName')]", |
| 40 | + "properties": { |
| 41 | + "addressPrefix": "10.0.0.0/24" |
| 42 | + } |
| 43 | + }] |
| 44 | + } |
| 45 | + }, |
| 46 | + { |
| 47 | + "type": "Microsoft.Network/publicIPAddresses", |
| 48 | + "name": "[variables('publicIPAddressName')]", |
| 49 | + "location": "[resourceGroup().location]", |
| 50 | + "apiVersion": "2016-03-30", |
| 51 | + "properties": { |
| 52 | + "publicIPAllocationMethod": "Dynamic", |
| 53 | + "dnsSettings": { |
| 54 | + "domainNameLabel": "[toLower(substring(concat('existingvmss', uniqueString(resourceGroup().id)), 0, 16))]" |
| 55 | + } |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + "type": "Microsoft.Network/loadBalancers", |
| 60 | + "name": "[variables('loadBalancerName')]", |
| 61 | + "location": "[resourceGroup().location]", |
| 62 | + "apiVersion": "2016-03-30", |
| 63 | + "dependsOn": [ |
| 64 | + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]" |
| 65 | + ], |
| 66 | + "properties": { |
| 67 | + "frontendIPConfigurations": [{ |
| 68 | + "name": "LoadBalancerFrontEnd", |
| 69 | + "properties": { |
| 70 | + "publicIPAddress": { |
| 71 | + "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" |
| 72 | + } |
| 73 | + } |
| 74 | + }], |
| 75 | + "backendAddressPools": [{ |
| 76 | + "name": "[variables('bePoolName')]" |
| 77 | + }], |
| 78 | + "inboundNatPools": [{ |
| 79 | + "name": "[variables('natPoolName')]", |
| 80 | + "properties": { |
| 81 | + "frontendIPConfiguration": { |
| 82 | + "id": "[concat(resourceId('Microsoft.Network/loadBalancers',variables('loadBalancerName')),'/frontendIPConfigurations/loadBalancerFrontEnd')]" |
| 83 | + }, |
| 84 | + "protocol": "tcp", |
| 85 | + "frontendPortRangeStart": 50000, |
| 86 | + "frontendPortRangeEnd": 50119, |
| 87 | + "backendPort": 3389 |
| 88 | + } |
| 89 | + }] |
| 90 | + } |
| 91 | + }, |
| 92 | + { |
| 93 | + "type": "Microsoft.Compute/virtualMachineScaleSets", |
| 94 | + "name": "existingvmss", |
| 95 | + "location": "[resourceGroup().location]", |
| 96 | + "apiVersion": "2017-03-30", |
| 97 | + "dependsOn": [ |
| 98 | + "[concat('Microsoft.Network/loadBalancers/', variables('loadBalancerName'))]", |
| 99 | + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" |
| 100 | + ], |
| 101 | + "sku": { |
| 102 | + "name": "Standard_D1_v2", |
| 103 | + "tier": "Standard", |
| 104 | + "capacity": 2 |
| 105 | + }, |
| 106 | + "properties": { |
| 107 | + "overprovision": true, |
| 108 | + "upgradePolicy": { |
| 109 | + "mode": "Manual" |
| 110 | + }, |
| 111 | + "virtualMachineProfile": { |
| 112 | + "storageProfile": { |
| 113 | + "osDisk": { |
| 114 | + "createOption": "FromImage" |
| 115 | + }, |
| 116 | + "imageReference": { |
| 117 | + "publisher": "MicrosoftWindowsServer", |
| 118 | + "offer": "WindowsServer", |
| 119 | + "sku": "2012-R2-Datacenter", |
| 120 | + "version": "latest" |
| 121 | + } |
| 122 | + }, |
| 123 | + "osProfile": { |
| 124 | + "computerNamePrefix": "existvmss", |
| 125 | + "adminUsername": "[parameters('adminUsername')]", |
| 126 | + "adminPassword": "[parameters('adminPassword')]" |
| 127 | + }, |
| 128 | + "networkProfile": { |
| 129 | + "networkInterfaceConfigurations": [{ |
| 130 | + "name": "[concat(variables('namingInfix'), 'nic')]", |
| 131 | + "properties": { |
| 132 | + "primary": true, |
| 133 | + "ipConfigurations": [{ |
| 134 | + "name": "[concat(variables('namingInfix'), 'ipconfig')]", |
| 135 | + "properties": { |
| 136 | + "subnet": { |
| 137 | + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]" |
| 138 | + }, |
| 139 | + "loadBalancerBackendAddressPools": [{ |
| 140 | + "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('bePoolName'))]" |
| 141 | + }], |
| 142 | + "loadBalancerInboundNatPools": [{ |
| 143 | + "id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools', variables('loadBalancerName'), variables('natPoolName'))]" |
| 144 | + }] |
| 145 | + } |
| 146 | + }] |
| 147 | + } |
| 148 | + }] |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + }, |
| 153 | + { |
| 154 | + "type": "Microsoft.Insights/autoscaleSettings", |
| 155 | + "apiVersion": "2015-04-01", |
| 156 | + "name": "cpuautoscale", |
| 157 | + "location": "[resourceGroup().location]", |
| 158 | + "dependsOn": [ |
| 159 | + "[concat('Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]" |
| 160 | + ], |
| 161 | + "properties": { |
| 162 | + "name": "cpuautoscale", |
| 163 | + "targetResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", |
| 164 | + "enabled": true, |
| 165 | + "profiles": [{ |
| 166 | + "name": "Profile1", |
| 167 | + "capacity": { |
| 168 | + "minimum": "1", |
| 169 | + "maximum": "10", |
| 170 | + "default": "1" |
| 171 | + }, |
| 172 | + "rules": [{ |
| 173 | + "metricTrigger": { |
| 174 | + "metricName": "Percentage CPU", |
| 175 | + "metricNamespace": "", |
| 176 | + "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", |
| 177 | + "timeGrain": "PT1M", |
| 178 | + "statistic": "Average", |
| 179 | + "timeWindow": "PT5M", |
| 180 | + "timeAggregation": "Average", |
| 181 | + "operator": "GreaterThan", |
| 182 | + "threshold": 50 |
| 183 | + }, |
| 184 | + "scaleAction": { |
| 185 | + "direction": "Increase", |
| 186 | + "type": "ChangeCount", |
| 187 | + "value": "1", |
| 188 | + "cooldown": "PT5M" |
| 189 | + } |
| 190 | + }, |
| 191 | + { |
| 192 | + "metricTrigger": { |
| 193 | + "metricName": "Percentage CPU", |
| 194 | + "metricNamespace": "", |
| 195 | + "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", |
| 196 | + "timeGrain": "PT1M", |
| 197 | + "statistic": "Average", |
| 198 | + "timeWindow": "PT5M", |
| 199 | + "timeAggregation": "Average", |
| 200 | + "operator": "LessThan", |
| 201 | + "threshold": 30 |
| 202 | + }, |
| 203 | + "scaleAction": { |
| 204 | + "direction": "Decrease", |
| 205 | + "type": "ChangeCount", |
| 206 | + "value": "1", |
| 207 | + "cooldown": "PT5M" |
| 208 | + } |
| 209 | + } |
| 210 | + ] |
| 211 | + }] |
| 212 | + } |
| 213 | + } |
| 214 | + ], |
| 215 | + "outputs": { |
| 216 | + "existingVmssName": { |
| 217 | + "type": "string", |
| 218 | + "value": "existingvmss" |
| 219 | + } |
| 220 | + } |
| 221 | +} |
0 commit comments