Virtual Machine


The Virtual Machine builder creates a fully configured virtual machine and all its required child resources.

  • Virtual Machines (Microsoft.Compute/virtualMachines)
  • Virtual Networks (Microsoft.Network/virtualNetworks)
  • IP Addresses (Microsoft.Network/publicIPAddresses)
  • Network Interfaces (Microsoft.Network/networkInterfaces)
  • Storage Accounts (Microsoft.Storage/storageAccounts)

In addition, every VM you create will add a SecureString parameter to the ARM template, whose name follows the pattern password-for-[virtual machine name].

Builder Keywords

nameSets the name of the VM.
diagnostics_supportTurns on diagnostics support using an automatically created created storage account.
diagnostics_support_externalTurns on diagnostics support using an existing storage account.
vm_sizeSets the size of the VM.
usernameSets the admin username of the VM (note: the password is supplied as a securestring parameter to the generated ARM template).
operating_systemSets the operating system of the VM. A set of samples is provided in the CommonImages module.
os_diskSets the size and type of the OS disk for the VM.
add_diskAdds a data disk to the VM with a specific size and type.
add_ssd_diskAdds a SSD data disk to the VM with a specific size.
add_slow_diskAdds a conventional (non-SSD) data disk to the VM with a specific size.
domain_name_prefixSets the prefix for the domain name of the VM.
address_prefixSets the IP address prefix of the VM.
subnet_prefixSets the subnet prefix of the VM.
custom_scriptExecutes the supplied inline custom script on the VM.
custom_script_filesUploads the supplied set of files, specified by URI, to the VM on creation.

Configuration Members

NicNameProvides the resource name of the Network Interface Card (NIC)
VnetNameProvides the resource name of the Virtual Network (VNet)
SubnetNameProvides the resource name of the subnet
IpNameProvides the resource name of the IP Address
HostnameReturns an ARM expression to retrieve the fully-qualified domain name from the virtual machine’s DNS settings.”


open Farmer
open Farmer.Builders

let myVm = vm {
    name "myFarmerVm"
    username "yourUsername"
    vm_size Vm.Standard_A2
    operating_system Vm.WindowsServer_2012Datacenter
    os_disk 128 Vm.StandardSSD_LRS
    add_ssd_disk 128
    add_slow_disk 512
    custom_script "powershell setup-vm.ps1" // you have to actually *call* the script
    custom_script_files [ "" ]