Autoscaling IaaS VMs in ARM mode from a template

I created a pattern-based deployment that overloads a number of Linux VMs. I would like to autoscale them according to classic examples, where Azure will enable / disable instances based on CPU load.

Is this possible with ARM mode? And if not, is there a suggested alternative method? The only examples I can find are using Application Insights and PaaS features. I have a Python application running in Docker on Ubuntu hosts.

+3


source to share


2 answers


For IaaS, you have to use a set of VM scales to use auto-scale, otherwise you have to stick with PaaS (web applications).



+1


source


To do this, you first need to create an availability group for the virtual machines. A resource declaration in an ARM template looks like this:

{
 "type": "Microsoft.Compute/availabilitySets",
  "name": "[variables('availabilitySetName')]",
  "apiVersion": "2015-05-01-preview",
  "location": "[parameters('location')]",
  "properties": {
       "platformFaultDomainCount": "2"
   }
}

      

Then, for a VM resource, the declaration in the ARM template would look something like this:

    {
            "apiVersion": "2015-05-01-preview",
            "type": "Microsoft.Compute/virtualMachines",
            "name": "[concat(variables('vmName'), '0')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
                "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), '0')]",
                "[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
            ],
            "properties": {
                "availabilitySet": {
                    "id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
                }, 
      ...},

      

Quckstart templates are a good ref: https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/201-2-vms-2-FDs-no-resource-loops/azuredeploy.json



Once you have two or more VMs of the same size in an availability set, you should set up autoscaling with microsoft.insights / autoscalesettings, which I believe you are linking to in the question. This is done on a cloud service, so it will work similarly to PaaS ... like this:

{
      "apiVersion": "2014-04-01",
      "name": "[concat(variables('vmName'), '-', resourceGroup().name)]",
      "type": "microsoft.insights/autoscalesettings",
      "location": "East US",
      ...},

      

Pretty good example: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/6abc9f320e39d9d75dffb60846e88ab80d3ff33a/201-web-app-sql-database/azuredeploy.json

I also set up autoscaling using the portal and parses ARMExplorer to get a better understanding of how things should look in my code. ARMExplorer is located here: Azure Resource Explorer

0


source







All Articles