Autoscale LANSA Windows VM ScaleSet with Azure SQL Database

Azure Public Test Date Azure Public Test Result

Azure US Gov Last Test Date Azure US Gov Last Test Result

Best Practice Check Cred Scan Check

Deploy To Azure Visualize

This template deploys a LANSA Windows Virtual Machine Scale Set integrated with Azure autoscale and Azure SQL Database

Tags: 'lansa, vmss, sql, autoscale, windows'

Endpoint Version Validated
Microsoft Azure - yes
Microsoft Azure Stack TP2 incompatible

Solution overview and deployed resources

The template deploys a Windows Virtual Machine Scale Set with a desired count of Virtual Machines in the scale set and a LANSA MSI to install into each Virtual Machine. Once the Virtual Machine Scale Set is deployed a custom script extension is used to install the LANSA MSI.

The Autoscale rules are configured as follows

  • sample for CPU (\Processor\PercentProcessorTime) in each VM every 1 Minute
  • if the Percent Processor Time is greater than 60% for 5 Minutes, then the scale out action (add 10% more Virtual Machine instances) is triggered
  • once the scale out action is completed, the cool down period is 20 Minutes
  • if the Percent Processor Time is less than 30% for 5 Minutes, then the scale in action (remove one Virtual Machine instance) is triggered
  • once the scale in action is completed, the cool down period is 5 Minutes

Resources Deployed

  • A Virtual Network
  • Six Storage Accounts for deploying up to 100 virtual machines
  • Two public ip addresses, one for each Load Balancer
  • One Application Gateway with SSL certificate
  • Two external Load Balancers
  • One Virtual Machine Scale Set to contain the single virtual machine which is responsible for configuring the database
  • One Virtual Machine Scale Set to contain the number of web servers requested by the deployer
  • The Virtual Machines are all instantiated from the Marketplace LANSA SKU lansa-scalable-license. There is a software cost for using this image. Click here for details.
  • Optionally, one Azure SQL Database server with one database, configured as per settings provided by the deployer


Before deploying this template you must:

  • Construct your LANSA application using Visual LANSA Version 14.1 with EPCs 141010, 141011 and 141013 applied, or later.
  • Construct a deployment image MSI using the LANSA Deployment Tool provided with Visual LANSA.
  • Upload your LANSA Web Application MSI to Azure BLOB storage and obtain the URL of the MSI. Note that the template includes a demonstration application so it is not strictly necessary to create a LANSA MSI in order to use the template.
  • Obtain an SSL certificate for your web site and convert it to a base64 encoded string. To get the certificate data from a pfx file in PowerShell you can use this: [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes("path to pfx file"))
  • Its also highly recommended to follow the usage instructions below :)

Usage Instructions

For full instructions for using this template go to Azure Deployment Tutorial


  1. Two VMSS. One to install the database; one to run the web site. OverProvision = false. This is so that extra VMs are not created which would put more load on the database which slows down provisioning. Failure to provision has not been seen. A second reason is that the database installer VMSS MUST NEVER have more than 1 instance installing at a time. Errors occur when publishing the weblets. As well as the database state not being matched to what the VM thinks the state of the database is in terms of table creation, etc.

  2. Database VMSS

  3. Only 1 instance ever. If instance dies another one is created.

  4. This instance is not currently used by the web site as 1 load balancer may only be configured for a single VMSS.

  5. Installed with SUDB=1. Otherwise commandToExecute is identical.

  6. Web Site VMSS

  7. Creator of stack specifies the minimum and maximum number of instances for autoscaling.

  8. The minimum number of instances is also the starting capacity for the VMSS. Scaling events alter the VMSS capacity which in turn causes a vm to be created or deleted in order to bring the current instance count in line with the VMSS capacity.

  9. Installed with SUDB=0. Otherwise commandToExecute is identical.

  10. Scale Out fast. Scale Out action is 10% of current instances. It scales out after 5 mins of avg CPU > 60%. Another scaling event will not occur for 20 minutes. This allows time for the VM to be installed.

  11. Scale in slowly. Scale in action is 1 VM at a time after 5 mins of avg CPU < 30%. Another scaling event will not occur for 5 mins. Deletion does not take very long. Allows more VMs to be deleted or another to be created.

Tags: Microsoft.Network/virtualNetworks, Microsoft.Network/publicIPAddresses, Microsoft.Network/loadBalancers, Microsoft.Compute/virtualMachineScaleSets, CustomScriptExtension, Microsoft.Insights/autoscaleSettings, PercentChangeCount, ChangeCount, Microsoft.Network/applicationGateways, Microsoft.Sql/servers, databases, firewallRules