diff --git a/201-vmss-scale-existing/azuredeploy.json b/201-vmss-scale-existing/azuredeploy.json index 91ee58375889..27c524fab936 100644 --- a/201-vmss-scale-existing/azuredeploy.json +++ b/201-vmss-scale-existing/azuredeploy.json @@ -1,37 +1,74 @@ { "$schema":"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion":"1.0.0.0", - "parameters":{ - "existingVMSSName":{ - "type":"string", - "metadata":{ - "description":"Name of existing VM Scale Set" - } - }, - "newCapacity":{ - "type":"int", - "metadata":{ - "description":"Number of desired VM instances" - } - }, - "vmSku": { + "parameters": { + "namingInfix": { "type": "string", - "defaultValue": "Standard_D1_v2", "metadata": { - "description": "Size of VMs in the VM Scale Set." + "description": "Naming infix of existing VM Scale Set." } } }, "resources":[ { - "type":"Microsoft.Compute/virtualMachineScaleSets", - "apiVersion":"2017-03-30", - "name":"[parameters('existingVMSSName')]", - "location":"[resourceGroup().location]", - "sku":{ - "name":"[parameters('vmSku')]", - "tier":"Standard", - "capacity":"[parameters('newCapacity')]" + "type": "Microsoft.Insights/autoscaleSettings", + "apiVersion": "2015-04-01", + "name": "autoscalewad", + "location": "[resourceGroup().location]", + "properties": { + "name": "autoscalewad", + "targetResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets/', parameters('namingInfix'))]", + "enabled": true, + "profiles": [ + { + "name": "Profile1", + "capacity": { + "minimum": "1", + "maximum": "10", + "default": "1" + }, + "rules": [ + { + "metricTrigger": { + "metricName": "Percentage CPU", + "metricNamespace": "", + "metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets/', parameters('namingInfix'))]", + "timeGrain": "PT1M", + "statistic": "Average", + "timeWindow": "PT5M", + "timeAggregation": "Average", + "operator": "GreaterThan", + "threshold": 60 + }, + "scaleAction": { + "direction": "Increase", + "type": "ChangeCount", + "value": "3", + "cooldown": "PT1M" + } + }, + { + "metricTrigger": { + "metricName": "Percentage CPU", + "metricNamespace": "", + "metricResourceUri": "[resourceId('Microsoft.Compute/virtualMachineScaleSets/', parameters('namingInfix'))]", + "timeGrain": "PT1M", + "statistic": "Average", + "timeWindow": "PT5M", + "timeAggregation": "Average", + "operator": "LessThan", + "threshold": 30 + }, + "scaleAction": { + "direction": "Decrease", + "type": "ChangeCount", + "value": "1", + "cooldown": "PT5M" + } + } + ] + } + ] } } ] diff --git a/201-vmss-scale-existing/azuredeploy.parameters.json b/201-vmss-scale-existing/azuredeploy.parameters.json index 7a2d68fb4135..df8521222958 100644 --- a/201-vmss-scale-existing/azuredeploy.parameters.json +++ b/201-vmss-scale-existing/azuredeploy.parameters.json @@ -2,11 +2,8 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "existingVMSSName": { - "value": "GET-PREREQ-existingVmssName" - }, - "newCapacity": { - "value": 3 + "namingInfix": { + "value": "GET-PREREQ-namingInfix" } } } diff --git a/201-vmss-scale-existing/prereqs/.settings.json b/201-vmss-scale-existing/prereqs/.settings.json new file mode 100644 index 000000000000..154e82537a39 --- /dev/null +++ b/201-vmss-scale-existing/prereqs/.settings.json @@ -0,0 +1,4 @@ +{ + "comment": "If prereqs need to be deployed to the same resourceGroup as the rest of the sample set the PrereqResourceGroupNameSuffix property to an empty string - otherwise you can omit this file", + "PrereqResourceGroupNameSuffix": "" +} \ No newline at end of file diff --git a/201-vmss-scale-existing/prereqs/prereq.azuredeploy.json b/201-vmss-scale-existing/prereqs/prereq.azuredeploy.json index 6e641ac889cd..544978f15db9 100644 --- a/201-vmss-scale-existing/prereqs/prereq.azuredeploy.json +++ b/201-vmss-scale-existing/prereqs/prereq.azuredeploy.json @@ -1,221 +1,251 @@ { - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "adminUsername": { - "type": "string", - "metadata": { - "description": "Name of existing VM Scale Set" - } - }, - "adminPassword": { - "type": "securestring", - "metadata": { - "description": "Number of desired VM instances" - } - } + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "vmSku": { + "type": "string", + "defaultValue": "Standard_A1", + "metadata": { + "description": "Size of VMs in the VM Scale Set." + } + }, + "ubuntuOSVersion": { + "type": "string", + "defaultValue": "16.04-LTS", + "allowedValues": [ + "14.04.4-LTS", + "16.04-LTS" + ], + "metadata": { + "description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version. Allowed values are: 15.10, 14.04.4-LTS." + } + }, + "vmssName": { + "type": "string", + "metadata": { + "description": "String used as a base for naming resources. Must be 3-61 characters in length and globally unique across Azure. A hash is prepended to this string for some resources, and resource-specific information is appended." + }, + "maxLength": 61 + }, + "instanceCount": { + "type": "int", + "metadata": { + "description": "Number of VM instances (100 or less)." + }, + "maxValue": 100 + }, + "adminUsername": { + "type": "string", + "metadata": { + "description": "Admin username on all VMs." + } }, - "variables": { - "namingInfix": "existingvmss", - "virtualNetworkName": "[concat(variables('namingInfix'), 'vnet')]", - "publicIPAddressName": "[concat(variables('namingInfix'), 'pip')]", - "subnetName": "[concat(variables('namingInfix'), 'subnet')]", - "loadBalancerName": "[concat(variables('namingInfix'), 'lb')]", - "natPoolName": "[concat(variables('namingInfix'), 'natpool')]", - "bePoolName": "[concat(variables('namingInfix'), 'bepool')]" + "authenticationType": { + "type": "string", + "defaultValue": "sshPublicKey", + "allowedValues": [ + "sshPublicKey", + "password" + ], + "metadata": { + "description": "Type of authentication to use on the Virtual Machine. SSH key is recommended." + } }, - "resources": [{ - "type": "Microsoft.Network/virtualNetworks", - "name": "[variables('virtualNetworkName')]", - "location": "[resourceGroup().location]", - "apiVersion": "2016-03-30", + "adminPasswordOrKey": { + "type": "securestring", + "metadata": { + "description": "SSH Key or password for the Virtual Machine. SSH key is recommended." + } + } + }, + "variables": { + "vmssName": "[parameters('vmssName')]", + "namingInfix": "[toLower(substring(concat(parameters('vmssName'), uniqueString(resourceGroup().id)), 0, 9))]", + "longNamingInfix": "[toLower(parameters('vmssName'))]", + "addressPrefix": "10.0.0.0/16", + "subnetPrefix": "10.0.0.0/24", + "virtualNetworkName": "[concat(variables('namingInfix'), 'vnet')]", + "publicIPAddressName": "[concat(variables('namingInfix'), 'pip')]", + "subnetName": "[concat(variables('namingInfix'), 'subnet')]", + "loadBalancerName": "[concat(variables('namingInfix'), 'lb')]", + "publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]", + "lbID": "[resourceId('Microsoft.Network/loadBalancers',variables('loadBalancerName'))]", + "natPoolName": "[concat(variables('namingInfix'), 'natpool')]", + "bePoolName": "[concat(variables('namingInfix'), 'bepool')]", + "natStartPort": 50000, + "natEndPort": 50119, + "natBackendPort": 22, + "nicName": "[concat(variables('namingInfix'), 'nic')]", + "ipConfigName": "[concat(variables('namingInfix'), 'ipconfig')]", + "frontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/loadBalancerFrontEnd')]", + "osType": { + "publisher": "Canonical", + "offer": "UbuntuServer", + "sku": "[parameters('ubuntuOSVersion')]", + "version": "latest" + }, + "imageReference": "[variables('osType')]", + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "ssh": { + "publicKeys": [ + { + "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]", + "keyData": "[parameters('adminPasswordOrKey')]" + } + ] + } + } + }, + "resources": [ + { + "type": "Microsoft.Network/virtualNetworks", + "name": "[variables('virtualNetworkName')]", + "location": "[resourceGroup().location]", + "apiVersion": "2017-04-01", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", "properties": { - "addressSpace": { - "addressPrefixes": [ - "10.0.0.0/16" - ] - }, - "subnets": [{ - "name": "[variables('subnetName')]", - "properties": { - "addressPrefix": "10.0.0.0/24" - } - }] + "addressPrefix": "[variables('subnetPrefix')]" } - }, - { - "type": "Microsoft.Network/publicIPAddresses", - "name": "[variables('publicIPAddressName')]", - "location": "[resourceGroup().location]", - "apiVersion": "2016-03-30", + } + ] + } + }, + { + "type": "Microsoft.Network/publicIPAddresses", + "name": "[variables('publicIPAddressName')]", + "location": "[resourceGroup().location]", + "apiVersion": "2017-04-01", + "properties": { + "publicIPAllocationMethod": "Dynamic", + "dnsSettings": { + "domainNameLabel": "[variables('longNamingInfix')]" + } + } + }, + { + "type": "Microsoft.Network/loadBalancers", + "name": "[variables('loadBalancerName')]", + "location": "[resourceGroup().location]", + "apiVersion": "2017-04-01", + "dependsOn": [ + "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + ], + "properties": { + "frontendIPConfigurations": [ + { + "name": "LoadBalancerFrontEnd", "properties": { - "publicIPAllocationMethod": "Dynamic", - "dnsSettings": { - "domainNameLabel": "[toLower(substring(concat('existingvmss', uniqueString(resourceGroup().id)), 0, 16))]" - } + "publicIPAddress": { + "id": "[variables('publicIPAddressID')]" + } } - }, - { - "type": "Microsoft.Network/loadBalancers", - "name": "[variables('loadBalancerName')]", - "location": "[resourceGroup().location]", - "apiVersion": "2016-03-30", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]" - ], + } + ], + "backendAddressPools": [ + { + "name": "[variables('bePoolName')]" + } + ], + "inboundNatPools": [ + { + "name": "[variables('natPoolName')]", "properties": { - "frontendIPConfigurations": [{ - "name": "LoadBalancerFrontEnd", - "properties": { - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" - } - } - }], - "backendAddressPools": [{ - "name": "[variables('bePoolName')]" - }], - "inboundNatPools": [{ - "name": "[variables('natPoolName')]", - "properties": { - "frontendIPConfiguration": { - "id": "[concat(resourceId('Microsoft.Network/loadBalancers',variables('loadBalancerName')),'/frontendIPConfigurations/loadBalancerFrontEnd')]" - }, - "protocol": "Tcp", - "frontendPortRangeStart": 50000, - "frontendPortRangeEnd": 50119, - "backendPort": 3389 - } - }] + "frontendIPConfiguration": { + "id": "[variables('frontEndIPConfigID')]" + }, + "protocol": "Tcp", + "frontendPortRangeStart": "[variables('natStartPort')]", + "frontendPortRangeEnd": "[variables('natEndPort')]", + "backendPort": "[variables('natBackendPort')]" } + } + ] + } + }, + { + "type": "Microsoft.Compute/virtualMachineScaleSets", + "name": "[variables('namingInfix')]", + "location": "[resourceGroup().location]", + "apiVersion": "2017-03-30", + "dependsOn": [ + "[resourceId('Microsoft.Network/loadBalancers/', variables('loadBalancerName'))]", + "[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "sku": { + "name": "[parameters('vmSku')]", + "tier": "Standard", + "capacity": "[parameters('instanceCount')]" + }, + "properties": { + "overprovision": true, + "upgradePolicy": { + "mode": "Manual" }, - { - "type": "Microsoft.Compute/virtualMachineScaleSets", - "name": "existingvmss", - "location": "[resourceGroup().location]", - "apiVersion": "2017-03-30", - "dependsOn": [ - "[concat('Microsoft.Network/loadBalancers/', variables('loadBalancerName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "sku": { - "name": "Standard_D1_v2", - "tier": "Standard", - "capacity": 2 + "virtualMachineProfile": { + "storageProfile": { + "osDisk": { + "createOption": "FromImage", + "caching": "ReadWrite" }, - "properties": { - "overprovision": true, - "upgradePolicy": { - "mode": "Manual" - }, - "virtualMachineProfile": { - "storageProfile": { - "osDisk": { - "createOption": "FromImage" + "imageReference": "[variables('imageReference')]" + }, + "osProfile": { + "computerNamePrefix": "[variables('namingInfix')]", + "adminUsername": "[parameters('adminUsername')]", + "adminPassword": "[parameters('adminPasswordOrKey')]", + "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]" + }, + "networkProfile": { + "networkInterfaceConfigurations": [ + { + "name": "[variables('nicName')]", + "properties": { + "primary": true, + "ipConfigurations": [ + { + "name": "[variables('ipConfigName')]", + "properties": { + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]" }, - "imageReference": { - "publisher": "MicrosoftWindowsServer", - "offer": "WindowsServer", - "sku": "2012-R2-Datacenter", - "version": "latest" - } - }, - "osProfile": { - "computerNamePrefix": "existvmss", - "adminUsername": "[parameters('adminUsername')]", - "adminPassword": "[parameters('adminPassword')]" - }, - "networkProfile": { - "networkInterfaceConfigurations": [{ - "name": "[concat(variables('namingInfix'), 'nic')]", - "properties": { - "primary": true, - "ipConfigurations": [{ - "name": "[concat(variables('namingInfix'), 'ipconfig')]", - "properties": { - "subnet": { - "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]" - }, - "loadBalancerBackendAddressPools": [{ - "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('bePoolName'))]" - }], - "loadBalancerInboundNatPools": [{ - "id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools', variables('loadBalancerName'), variables('natPoolName'))]" - }] - } - }] - } - }] + "loadBalancerBackendAddressPools": [ + { + "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('bePoolName'))]" + } + ], + "loadBalancerInboundNatPools": [ + { + "id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools', variables('loadBalancerName'), variables('natPoolName'))]" + } + ] + } } + ] } - } - }, - { - "type": "Microsoft.Insights/autoscaleSettings", - "apiVersion": "2015-04-01", - "name": "cpuautoscale", - "location": "[resourceGroup().location]", - "dependsOn": [ - "[concat('Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]" - ], - "properties": { - "name": "cpuautoscale", - "targetResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", - "enabled": true, - "profiles": [{ - "name": "Profile1", - "capacity": { - "minimum": "1", - "maximum": "10", - "default": "1" - }, - "rules": [{ - "metricTrigger": { - "metricName": "Percentage CPU", - "metricNamespace": "", - "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", - "timeGrain": "PT1M", - "statistic": "Average", - "timeWindow": "PT5M", - "timeAggregation": "Average", - "operator": "GreaterThan", - "threshold": 50 - }, - "scaleAction": { - "direction": "Increase", - "type": "ChangeCount", - "value": "1", - "cooldown": "PT5M" - } - }, - { - "metricTrigger": { - "metricName": "Percentage CPU", - "metricNamespace": "", - "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', 'existingvmss')]", - "timeGrain": "PT1M", - "statistic": "Average", - "timeWindow": "PT5M", - "timeAggregation": "Average", - "operator": "LessThan", - "threshold": 30 - }, - "scaleAction": { - "direction": "Decrease", - "type": "ChangeCount", - "value": "1", - "cooldown": "PT5M" - } - } - ] - }] - } + } + ] + } } - ], - "outputs": { + } + } + ], + "outputs": { "existingVmssName": { "type": "string", - "value": "existingvmss" + "value": "[variables('vmssName')]" + }, + "namingInfix": { + "type": "string", + "value": "[variables('namingInfix')]" } } -} +} \ No newline at end of file diff --git a/201-vmss-scale-existing/prereqs/prereq.azuredeploy.parameters.json b/201-vmss-scale-existing/prereqs/prereq.azuredeploy.parameters.json index cdb415777c63..89713ba4579e 100644 --- a/201-vmss-scale-existing/prereqs/prereq.azuredeploy.parameters.json +++ b/201-vmss-scale-existing/prereqs/prereq.azuredeploy.parameters.json @@ -2,12 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - - "adminUsername": { - "value": "GEN-UNIQUE" - }, - "adminPassword": { - "value": "GEN-PASSWORD" - } + "vmSku": { + "value": "Standard_DS2_V2" + }, + "ubuntuOSVersion": { + "value": "16.04-LTS" + }, + "vmssName": { + "value": "GEN-UNIQUE-32" + }, + "instanceCount": { + "value": 2 + }, + "adminUsername": { + "value": "GEN-UNIQUE" + }, + "adminPasswordOrKey": { + "value": "GEN-SSH-PUB-KEY" + } } -} \ No newline at end of file + } \ No newline at end of file