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.
Microsoft.Compute/virtualMachineScaleSets
)Builder | Keyword | Purpose |
---|---|---|
vmss | name | Sets the name of the VM scale set. |
vmss | vm_profile | Defines a profile for VM’s in the scale set using the vm builder to support all the same functionality as a single VM. |
vmss | add_availability_zones | Adds one or more availability zones so VM resources will be distributed across those zones. |
vmss | add_extensions | Adds extensions that will be automatically installed on VMs when scaling out. |
vmss | automatic_repair_policy | Enables automatically replacing VMs in the scale set that report as unhealthy. Requires adding the Application Health Extension. |
vmss | automatic_repair_enabled_after | Defines a grace period after becoming unhealthy before replacing the instance. |
vmss | capacity | The number of VM instances in the scale set. |
vmss | health_probe | If not using an application health extension, this refers to a load balancer health probe that can indicate instance health. |
vmss | scale_in_policy | Specify the policy for determining which VMs to remove when scaling in. |
vmss | scale_in_force_deletion | Indicates the VMs should be force deleted so they free the resources more quickly. |
vmss | upgrade_mode | Specify 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. |
applicationHealthExtension | vmss | When adding the extension as a resource, this specifies the VM scale set it should be applied to. |
applicationHealthExtension | os | Operating system (Linux or Windows) to install the correct extension for that OS. |
applicationHealthExtension | protocol | Protocol (TCP, HTTP, or HTTPS) to probe, and if specifying HTTP or HTTPS, include the path. |
applicationHealthExtension | port | TCP port to probe. |
applicationHealthExtension | interval | Interval to probe for health. |
applicationHealthExtension | number_of_probes | Sets the number times the probe must fail to consider this instance a failure. |
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
}
]
}