Virtual Machine Scale Set

Overview

The Virtual Machine Scale Set builder (vmss) creates a virtual machine scale set that can grow and shrink it’s capacity by creating virtual machines and their dependent resources from a common profile.

  • Virtual Machine Scale Sets (Microsoft.Compute/virtualMachineScaleSets)

Builder Keywords

BuilderKeywordPurpose
vmssnameSets the name of the VM scale set.
vmssvm_profileDefines a profile for VM’s in the scale set using the vm builder to support all the same functionality as a single VM.
vmssadd_availability_zonesAdds one or more availability zones so VM resources will be distributed across those zones.
vmssadd_extensionsAdds extensions that will be automatically installed on VMs when scaling out.
vmssautomatic_repair_policyEnables automatically replacing VMs in the scale set that report as unhealthy. Requires adding the Application Health Extension.
vmssautomatic_repair_enabled_afterDefines a grace period after becoming unhealthy before replacing the instance.
vmsscapacityThe number of VM instances in the scale set.
vmsshealth_probeIf not using an application health extension, this refers to a load balancer health probe that can indicate instance health.
vmssscale_in_policySpecify the policy for determining which VMs to remove when scaling in.
vmssscale_in_force_deletionIndicates the VMs should be force deleted so they free the resources more quickly.
vmssupgrade_modeSpecify Manual, Automatic, or Rolling upgrades. Rolling upgrades require the Application Health Extension or a Health Probe to ensure newly replaced instances are healthy before replacing more of them.
vmssosupgrade_automaticIndicates whether OS upgrades should automatically be applied to scale set instances in a rolling fashion when a newer version of the OS image becomes available. Default value is false. If this is set to true for Windows based scale sets, enableAutomaticUpdates is automatically set to false and cannot be set to true.
vmssosupgrade_automatic_rollbackWhether OS image rollback feature should be enabled. Enabled by default.
vmssosupgrade_rolling_upgradeIndicates whether rolling upgrade policy should be used during Auto OS Upgrade. Default value is false. Auto OS Upgrade will fallback to the default policy if no policy is defined on the VMSS.
vmssosupgrade_rolling_upgrade_deferralIndicates whether Auto OS Upgrade should undergo deferral. Deferred OS upgrades will send advanced notifications on a per-VM basis that an OS upgrade from rolling upgrades is incoming, via the IMDS tag ‘Platform.PendingOSUpgrade’. The upgrade then defers until the upgrade is approved via an ApproveRollingUpgrade call.
applicationHealthExtensionvmssWhen adding the extension as a resource, this specifies the VM scale set it should be applied to.
applicationHealthExtensionosOperating system (Linux or Windows) to install the correct extension for that OS.
applicationHealthExtensionprotocolProtocol (TCP, HTTP, or HTTPS) to probe, and if specifying HTTP or HTTPS, include the path.
applicationHealthExtensionportTCP port to probe.
applicationHealthExtensionintervalInterval to probe for health.
applicationHealthExtensionnumber_of_probesSets the number of times the probe must fail to consider this instance a failure.

Example

This example creates a scale set with 3 VM instances and includes the Application Health Extension to support rolling updates and automatic repairs.

open Farmer
open Farmer.Builders
open Farmer.Vm
open Farmer.VmScaleSet

vmss {
    name "my-scale-set"
    capacity 3

    vm_profile (
        vm {
            username "azureuser"
            operating_system UbuntuServer_2204LTS
            vm_size Standard_B1s
            os_disk 128 StandardSSD_LRS
            diagnostics_support_managed
            custom_script "sudo apt update && sudo apt install -y nginx"
        }
    )
    scale_in_policy OldestVM
    upgrade_mode Rolling
    automatic_repair_enabled_after (System.TimeSpan.FromMinutes 10)
    add_extensions [
        applicationHealthExtension {
            protocol (ApplicationHealthExtensionProtocol.HTTP "/healthcheck")
            port 80
            os Linux
        }
    ]

}