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).
password_parameterSets the name of the parameter which contains the admin password for this VM. defaults to “password-for-”
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. Note: The default is non-SSD.
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. Supports only one command. Alternatively you can connect VM e.g. with Powershell Invoke-AzVMRunCommand.
custom_script_filesUploads the supplied set of files, specified by URI, to the VM on creation.
custom_dataSets the custom data field for the VM.
public_ipSpecifies or removes the public IP for this VM
ip_allocationSets the public IP as Dynamic or Static. Default is Dynamic.
disable_password_authenticationDisables password authentication on the VM. Must include at least one key if true
add_authorized_keyadds one authorized key
add_authorized_keysadds a list of authorized keys
add_identityAdds a managed identity to the Virtual Machine.
system_identityActivates the system identity of the Virtual Machine.
private_ip_allocationSets the private ip as Dynamic or Static default is dynamic.
network_security_groupSets the Network Security Group (NSG) for VM/NIC. Enables you to create and share firewall rule sets.
link_to_network_security_groupSpecify an existing Network Security Group (NSG) for VM/NIC.

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
PublicIpAddressReturns an ARM expression to retrieve public IP address of the virtual machine.
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 [ "" ]
    custom_data "customData"
    disable_password_authentication true
    add_authorized_key "fooPath" "fooKey"
    add_authorized_keys [("fooPath", "fooKey");("fooPath1", "fooKey1")]
    private_ip_allocation (PrivateIpAddress.StaticPrivateIp (Net.IPAddress.Parse("")))