Azure Compute Linux Virtual Machine
This page shows how to write Terraform and Azure Resource Manager for Compute Linux Virtual Machine and write them securely.
azurerm_linux_virtual_machine (Terraform)
The Linux Virtual Machine in Compute can be configured in Terraform with the resource name azurerm_linux_virtual_machine. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_linux_virtual_machine" "myVM1" {
name = "Master"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_size_fat
admin_username = "Antonio"
resource "azurerm_linux_virtual_machine" "NFS" {
name = "nfs"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_4GB_1vCPU
admin_username = var.ssh_user
resource "azurerm_linux_virtual_machine" "HaProxy" {
name = "HaProxy"
location = var.azure_location_Paris
resource_group_name = azurerm_resource_group.Ressource_Paris_HAProxy.name
network_interface_ids = [azurerm_network_interface.NIC_HaProxy.id]
size = "Standard_B1ls"
resource "azurerm_linux_virtual_machine" "myVM1" {
name = "master"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_size
admin_username = "pacman"
resource "azurerm_linux_virtual_machine" "web1" {
name = "web1"
resource_group_name = var.azurerm_resource_group_name
admin_username = "azureuser"
location = var.azurerm_resource_group_location
size = "Standard_B1ls"
resource "azurerm_linux_virtual_machine" "nginx-web-server-1" {
name = "nginx-web-server-1"
resource_group_name = azurerm_resource_group.nginx_rg.name
location = azurerm_resource_group.nginx_rg.location
size = "Standard_F2"
admin_username = var.admin_username
resource "azurerm_linux_virtual_machine" "deb01" {
name = "deb01-machine"
resource_group_name = azurerm_resource_group.transithub.name
location = azurerm_resource_group.transithub.location
size = "Standard_B1s"
admin_username = "##############"
resource "azurerm_linux_virtual_machine" "basic_a2" {
name = "basic_a2"
resource_group_name = "fake_resource_group"
location = "eastus"
size = "Basic_A2"
resource "azurerm_linux_virtual_machine" "dev-1" {
name = "example-machine"
resource_group_name = azurerm_resource_group.dev-rg.name
location = var.location
size = "Standard_F2"
admin_username = "adminuser"
resource "azurerm_linux_virtual_machine" "lpsc_VM1" {
name = "lpsc-azure-vm1"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_tamanyo
admin_username = var.ssh_user
Security Best Practices for azurerm_linux_virtual_machine
There is 1 setting in azurerm_linux_virtual_machine that should be taken care of for security reasons. The following section explain an overview and example code.
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
Parameters
-
admin_passwordoptional - string -
admin_usernamerequired - string -
allow_extension_operationsoptional - bool -
availability_set_idoptional - string -
computer_nameoptional computed - string -
custom_dataoptional - string -
dedicated_host_idoptional - string -
disable_password_authenticationoptional - bool -
encryption_at_host_enabledoptional - bool -
eviction_policyoptional - string -
extensions_time_budgetoptional - string -
idoptional computed - string -
license_typeoptional - string -
locationrequired - string -
max_bid_priceoptional - number -
namerequired - string -
network_interface_idsrequired - list of string -
platform_fault_domainoptional - number -
priorityoptional - string -
private_ip_addressoptional computed - string -
private_ip_addressesoptional computed - list of string -
provision_vm_agentoptional - bool -
proximity_placement_group_idoptional - string -
public_ip_addressoptional computed - string -
public_ip_addressesoptional computed - list of string -
resource_group_namerequired - string -
sizerequired - string -
source_image_idoptional - string -
tagsoptional - map from string to string -
virtual_machine_idoptional computed - string -
virtual_machine_scale_set_idoptional - string -
zoneoptional computed - string -
additional_capabilitieslist block-
ultra_ssd_enabledoptional - bool
-
-
admin_ssh_keyset block-
public_keyrequired - string -
usernamerequired - string
-
-
boot_diagnosticslist block-
storage_account_urioptional - string
-
-
identitylist block-
identity_idsoptional - set of string -
principal_idoptional computed - string -
tenant_idoptional computed - string -
typerequired - string
-
-
os_disklist block-
cachingrequired - string -
disk_encryption_set_idoptional - string -
disk_size_gboptional computed - number -
nameoptional computed - string -
storage_account_typerequired - string -
write_accelerator_enabledoptional - bool -
diff_disk_settingslist block-
optionrequired - string
-
-
-
planlist block -
secretlist block-
key_vault_idrequired - string -
certificateset block-
urlrequired - string
-
-
-
source_image_referencelist block -
timeoutssingle block
Explanation in Terraform Registry
Manages a Linux Virtual Machine.
Tips: Best Practices for The Other Azure Compute Resources
In addition to the azurerm_managed_disk, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_managed_disk
Ensure to enable the encryption on managed disks
It is better to enable the encryption on managed disks.
azurerm_virtual_machine
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
Microsoft.Compute/virtualMachines (Azure Resource Manager)
The virtualMachines in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/virtualMachines. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('SharedVmConfig').vmSize]"
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('SharedVmConfig').vmSize]"
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"dependsOn": [
"[variables('ImageName')]"
],
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('SharedVmConfig').vmSize]"
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"dependsOn": [],
"properties": {
"hardwareProfile": {
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('SharedVmConfig').location]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('SharedVmConfig').vmSize]"
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"apiVersion": "2017-03-30",
"location": "[parameters('vmLocation')]",
"identity": {
"type": "SystemAssigned"
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"Microsoft.Network/networkInterfaces/dc1nic1"
],
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "[parameters('computeSettings').computeApiVersion]",
"location": "[parameters('computeSettings').location]",
"properties": {
"osProfile": {
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
Parameters
apiVersionrequired - stringextendedLocationoptionalnameoptional - stringThe name of the extended location.
typeoptional - stringThe type of the extended location.
identityoptionaltypeoptional - stringThe type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine.
userAssignedIdentitiesoptional - undefinedThe list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
locationrequired - stringResource location
namerequired - stringThe name of the virtual machine.
planoptionalnameoptional - stringThe plan ID.
productoptional - stringSpecifies the product of the image from the marketplace. This is the same value as Offer under the imageReference element.
promotionCodeoptional - stringThe promotion code.
publisheroptional - stringThe publisher ID.
propertiesrequiredadditionalCapabilitiesoptionalhibernationEnabledoptional - booleanThe flag that enables or disables hibernation capability on the VM.
ultraSSDEnabledoptional - booleanThe flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled.
applicationProfileoptionalgalleryApplicationsoptional arrayconfigurationReferenceoptional - stringOptional, Specifies the uri to an azure blob that will replace the default configuration for the package if provided
orderoptional - integerOptional, Specifies the order in which the packages have to be installed
packageReferenceIdrequired - stringSpecifies the GalleryApplicationVersion resource id on the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}
tagsoptional - stringOptional, Specifies a passthrough value for more generic context.
availabilitySetoptionalidoptional - stringResource Id
billingProfileoptionalmaxPriceoptional - numberSpecifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. This price is in US Dollars. This price will be compared with the current Azure Spot price for the VM size. Also, the prices are compared at the time of create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is greater than the current Azure Spot price. The maxPrice will also be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the maxPrice after creation of VM/VMSS. Possible values are: - Any decimal value greater than zero. Example: 0.01538 -1 – indicates default price to be up-to on-demand. You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. Minimum api-version: 2019-03-01.
capacityReservationoptionalcapacityReservationGroupoptionalidoptional - stringResource Id
diagnosticsProfileoptionalbootDiagnosticsoptionalenabledoptional - booleanWhether boot diagnostics should be enabled on the Virtual Machine.
storageUrioptional - stringUri of the storage account to use for placing the console output and screenshot. If storageUri is not specified while enabling boot diagnostics, managed storage will be used.
evictionPolicyoptional - stringSpecifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview.
extensionsTimeBudgetoptional - stringSpecifies the time alloted for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). Minimum api-version: 2020-06-01
hardwareProfileoptionalvmSizeoptional - stringSpecifies the size of the virtual machine. The enum data type is currently deprecated and will be removed by December 23rd 2023. Recommended way to get the list of available sizes is using these APIs: List all available virtual machine sizes in an availability set List all available virtual machine sizes in a region List all available virtual machine sizes for resizing. For more information about virtual machine sizes, see Sizes for virtual machines. The available VM sizes depend on region and availability set.
vmSizePropertiesoptionalvCPUsAvailableoptional - integerSpecifies the number of vCPUs available for the VM. When this property is not specified in the request body the default behavior is to set it to the value of vCPUs available for that VM size exposed in api response of List all available virtual machine sizes in a region .
vCPUsPerCoreoptional - integerSpecifies the vCPU to physical core ratio. When this property is not specified in the request body the default behavior is set to the value of vCPUsPerCore for the VM Size exposed in api response of List all available virtual machine sizes in a region Setting this property to 1 also means that hyper-threading is disabled.
hostoptionalidoptional - stringResource Id
hostGroupoptionalidoptional - stringResource Id
licenseTypeoptional - stringSpecifies that the image or disk that is being used was licensed on-premises. Possible values for Windows Server operating system are: Windows_Client Windows_Server Possible values for Linux Server operating system are: RHEL_BYOS (for RHEL) SLES_BYOS (for SUSE) For more information, see Azure Hybrid Use Benefit for Windows Server Azure Hybrid Use Benefit for Linux Server Minimum api-version: 2015-06-15
networkProfileoptionalnetworkApiVersionoptional - stringspecifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations.
networkInterfaceConfigurationsoptional arraynamerequired - stringThe network interface configuration name.
propertiesoptionaldeleteOptionoptional - stringSpecify what happens to the network interface when the VM is deleted.
dnsSettingsoptionaldnsServersoptional - arrayList of DNS servers IP addresses
dscpConfigurationoptionalidoptional - stringResource Id
enableAcceleratedNetworkingoptional - booleanSpecifies whether the network interface is accelerated networking-enabled.
enableFpgaoptional - booleanSpecifies whether the network interface is FPGA networking-enabled.
enableIPForwardingoptional - booleanWhether IP forwarding enabled on this NIC.
ipConfigurationsrequired arraynamerequired - stringThe IP configuration name.
propertiesoptionalapplicationGatewayBackendAddressPoolsoptional arrayidoptional - stringResource Id
applicationSecurityGroupsoptional arrayidoptional - stringResource Id
loadBalancerBackendAddressPoolsoptional arrayidoptional - stringResource Id
primaryoptional - booleanSpecifies the primary network interface in case the virtual machine has more than 1 network interface.
privateIPAddressVersionoptional - stringAvailable from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'.
publicIPAddressConfigurationoptionalnamerequired - stringThe publicIP address configuration name.
propertiesoptionaldeleteOptionoptional - stringSpecify what happens to the public IP address when the VM is deleted.
dnsSettingsoptionaldomainNameLabelrequired - stringThe Domain name label prefix of the PublicIPAddress resources that will be created. The generated name label is the concatenation of the domain name label and vm network profile unique ID.
idleTimeoutInMinutesoptional - integerThe idle timeout of the public IP address.
ipTagsoptional arrayipTagTypeoptional - stringIP tag type. Example: FirstPartyUsage.
tagoptional - stringIP tag associated with the public IP. Example: SQL, Storage etc.
publicIPAddressVersionoptional - stringAvailable from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'.
publicIPAllocationMethodoptional - stringSpecify the public IP allocation type.
publicIPPrefixoptionalidoptional - stringResource Id
skuoptionalnameoptional - stringSpecify public IP sku name.
tieroptional - stringSpecify public IP sku tier.
subnetoptionalidoptional - stringResource Id
networkSecurityGroupoptionalidoptional - stringResource Id
primaryoptional - booleanSpecifies the primary network interface in case the virtual machine has more than 1 network interface.
networkInterfacesoptional arrayidoptional - stringResource Id
propertiesoptionaldeleteOptionoptional - stringSpecify what happens to the network interface when the VM is deleted.
primaryoptional - booleanSpecifies the primary network interface in case the virtual machine has more than 1 network interface.
osProfileoptionaladminPasswordoptional - stringSpecifies the password of the administrator account. Minimum-length (Windows): 8 characters Minimum-length (Linux): 6 characters Max-length (Windows): 123 characters Max-length (Linux): 72 characters Complexity requirements: 3 out of 4 conditions below need to be fulfilled Has lower characters Has upper characters Has a digit Has a special character (Regex match [\W_]) Disallowed values: "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" For resetting the password, see How to reset the Remote Desktop service or its login password in a Windows VM For resetting root password, see Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension
adminUsernameoptional - stringSpecifies the name of the administrator account. This property cannot be updated after the VM is created. Windows-only restriction: Cannot end in "." Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". Minimum-length (Linux): 1 character Max-length (Linux): 64 characters Max-length (Windows): 20 characters.
allowExtensionOperationsoptional - booleanSpecifies whether extension operations should be allowed on the virtual machine. This may only be set to False when no extensions are present on the virtual machine.
computerNameoptional - stringSpecifies the host OS name of the virtual machine. This name cannot be updated after the VM is created. Max-length (Windows): 15 characters Max-length (Linux): 64 characters. For naming conventions and restrictions see Azure infrastructure services implementation guidelines.
customDataoptional - stringSpecifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum length of the binary array is 65535 bytes. Note: Do not pass any secrets or passwords in customData property This property cannot be updated after the VM is created. customData is passed to the VM to be saved as a file, for more information see Custom Data on Azure VMs For using cloud-init for your Linux VM, see Using cloud-init to customize a Linux VM during creation
linuxConfigurationoptionaldisablePasswordAuthenticationoptional - booleanSpecifies whether password authentication should be disabled.
patchSettingsoptionalassessmentModeoptional - stringSpecifies the mode of VM Guest Patch Assessment for the IaaS virtual machine. Possible values are: ImageDefault - You control the timing of patch assessments on a virtual machine. AutomaticByPlatform - The platform will trigger periodic patch assessments. The property provisionVMAgent must be true.
patchModeoptional - stringSpecifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible. Possible values are: ImageDefault - The virtual machine's default patching configuration is used. AutomaticByPlatform - The virtual machine will be automatically updated by the platform. The property provisionVMAgent must be true.
provisionVMAgentoptional - booleanIndicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.
sshoptionalpublicKeysoptional arraykeyDataoptional - stringSSH public key certificate used to authenticate with the VM through ssh. The key needs to be at least 2048-bit and in ssh-rsa format. For creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed).
pathoptional - stringSpecifies the full path on the created VM where ssh public key is stored. If the file already exists, the specified key is appended to the file. Example: /home/user/.ssh/authorized_keys
requireGuestProvisionSignaloptional - booleanSpecifies whether the guest provision signal is required to infer provision success of the virtual machine. Note: This property is for private testing only, and all customers must not set the property to false.
secretsoptional arraysourceVaultoptionalidoptional - stringResource Id
vaultCertificatesoptional arraycertificateStoreoptional - stringFor Windows VMs, specifies the certificate store on the Virtual Machine to which the certificate should be added. The specified certificate store is implicitly in the LocalMachine account. For Linux VMs, the certificate file is placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of these files are .pem formatted.
certificateUrloptional - stringThis is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see Add a key or secret to the key vault. In this case, your certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded in UTF-8: { "data":"<Base64-encoded-certificate>", "dataType":"pfx", "password":"<pfx-file-password>" } To install certificates on a virtual machine it is recommended to use the Azure Key Vault virtual machine extension for Linux or the Azure Key Vault virtual machine extension for Windows.
windowsConfigurationoptionaladditionalUnattendContentoptional arraycomponentNameoptional - stringThe component name. Currently, the only allowable value is Microsoft-Windows-Shell-Setup.
contentoptional - stringSpecifies the XML formatted content that is added to the unattend.xml file for the specified path and component. The XML must be less than 4KB and must include the root element for the setting or feature that is being inserted.
passNameoptional - stringThe pass name. Currently, the only allowable value is OobeSystem.
settingNameoptional - stringSpecifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon.
enableAutomaticUpdatesoptional - booleanIndicates whether Automatic Updates is enabled for the Windows virtual machine. Default value is true. For virtual machine scale sets, this property can be updated and updates will take effect on OS reprovisioning.
patchSettingsoptionalassessmentModeoptional - stringSpecifies the mode of VM Guest patch assessment for the IaaS virtual machine. Possible values are: ImageDefault - You control the timing of patch assessments on a virtual machine. AutomaticByPlatform - The platform will trigger periodic patch assessments. The property provisionVMAgent must be true.
enableHotpatchingoptional - booleanEnables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must be set to 'AutomaticByPlatform'.
patchModeoptional - stringSpecifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible. Possible values are: Manual - You control the application of patches to a virtual machine. You do this by applying patches manually inside the VM. In this mode, automatic updates are disabled; the property WindowsConfiguration.enableAutomaticUpdates must be false AutomaticByOS - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. AutomaticByPlatform - the virtual machine will automatically updated by the platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true.
provisionVMAgentoptional - booleanIndicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.
timeZoneoptional - stringSpecifies the time zone of the virtual machine. e.g. "Pacific Standard Time". Possible values can be TimeZoneInfo.Id value from time zones returned by TimeZoneInfo.GetSystemTimeZones.
winRMoptionallistenersoptional arraycertificateUrloptional - stringThis is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see Add a key or secret to the key vault. In this case, your certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded in UTF-8: { "data":"<Base64-encoded-certificate>", "dataType":"pfx", "password":"<pfx-file-password>" } To install certificates on a virtual machine it is recommended to use the Azure Key Vault virtual machine extension for Linux or the Azure Key Vault virtual machine extension for Windows.
protocoloptional - stringSpecifies the protocol of WinRM listener. Possible values are: http https.
platformFaultDomainoptional - integerSpecifies the scale set logical fault domain into which the Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned to a fault domain that best maintains balance across available fault domains. <li>This is applicable only if the 'virtualMachineScaleSet' property of this Virtual Machine is set.<li>The Virtual Machine Scale Set that is referenced, must have 'platformFaultDomainCount' > 1.<li>This property cannot be updated once the Virtual Machine is created.<li>Fault domain assignment can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01
priorityoptional - stringSpecifies the priority for the virtual machine. Minimum api-version: 2019-03-01.
proximityPlacementGroupoptionalidoptional - stringResource Id
scheduledEventsProfileoptionalterminateNotificationProfileoptionalenableoptional - booleanSpecifies whether the Terminate Scheduled event is enabled or disabled.
notBeforeTimeoutoptional - stringConfigurable length of time a Virtual Machine being deleted will have to potentially approve the Terminate Scheduled Event before the event is auto approved (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes (PT5M)
securityProfileoptionalencryptionAtHostoptional - booleanThis property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. Default: The Encryption at host will be disabled unless this property is set to true for the resource.
securityTypeoptional - stringSpecifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch.
uefiSettingsoptionalsecureBootEnabledoptional - booleanSpecifies whether secure boot should be enabled on the virtual machine. Minimum api-version: 2020-12-01
vTpmEnabledoptional - booleanSpecifies whether vTPM should be enabled on the virtual machine. Minimum api-version: 2020-12-01
storageProfileoptionaldataDisksoptional arraycachingoptional - stringSpecifies the caching requirements. Possible values are: None ReadOnly ReadWrite Default: None for Standard storage. ReadOnly for Premium storage.
createOptionrequired - stringSpecifies how the virtual machine should be created. Possible values are: Attach \u2013 This value is used when you are using a specialized disk to create the virtual machine. FromImage \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described.
deleteOptionoptional - stringSpecifies whether data disk should be deleted or detached upon VM deletion. Possible values: Delete If this value is used, the data disk is deleted when VM is deleted. Detach If this value is used, the data disk is retained after VM is deleted. The default value is set to detach.
detachOptionoptional - stringSpecifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: ForceDetach. detachOption: ForceDetach is applicable only for managed data disks. If a previous detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'.
diskSizeGBoptional - integerSpecifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. This value cannot be larger than 1023 GB
imageoptionalurioptional - stringSpecifies the virtual hard disk's uri.
lunrequired - integerSpecifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
managedDiskoptionaldiskEncryptionSetoptionalidoptional - stringResource Id
idoptional - stringResource Id
storageAccountTypeoptional - stringSpecifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.
nameoptional - stringThe disk name.
toBeDetachedoptional - booleanSpecifies whether the data disk is in process of detachment from the VirtualMachine/VirtualMachineScaleset
vhdoptionalurioptional - stringSpecifies the virtual hard disk's uri.
writeAcceleratorEnabledoptional - booleanSpecifies whether writeAccelerator should be enabled or disabled on the disk.
imageReferenceoptionalidoptional - stringResource Id
offeroptional - stringSpecifies the offer of the platform image or marketplace image used to create the virtual machine.
publisheroptional - stringThe image publisher.
sharedGalleryImageIdoptional - stringSpecified the shared gallery image unique id for vm deployment. This can be fetched from shared gallery image GET call.
skuoptional - stringThe image SKU.
versionoptional - stringSpecifies the version of the platform image or marketplace image used to create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically update after deploy time even if a new version becomes available.
osDiskoptionalcachingoptional - stringSpecifies the caching requirements. Possible values are: None ReadOnly ReadWrite Default: None for Standard storage. ReadOnly for Premium storage.
createOptionrequired - stringSpecifies how the virtual machine should be created. Possible values are: Attach \u2013 This value is used when you are using a specialized disk to create the virtual machine. FromImage \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described.
deleteOptionoptional - stringSpecifies whether OS Disk should be deleted or detached upon VM deletion. Possible values: Delete If this value is used, the OS disk is deleted when VM is deleted. Detach If this value is used, the os disk is retained after VM is deleted. The default value is set to detach. For an ephemeral OS Disk, the default value is set to Delete. User cannot change the delete option for ephemeral OS Disk.
diffDiskSettingsoptionaloptionoptional - stringSpecifies the ephemeral disk settings for operating system disk.
placementoptional - stringSpecifies the ephemeral disk placement for operating system disk. Possible values are: CacheDisk ResourceDisk Default: CacheDisk if one is configured for the VM size otherwise ResourceDisk is used. Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a cache disk.
diskSizeGBoptional - integerSpecifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. This value cannot be larger than 1023 GB
encryptionSettingsoptionaldiskEncryptionKeyoptionalsecretUrlrequired - stringThe URL referencing a secret in a Key Vault.
sourceVaultrequiredidoptional - stringResource Id
enabledoptional - booleanSpecifies whether disk encryption should be enabled on the virtual machine.
keyEncryptionKeyoptionalkeyUrlrequired - stringThe URL referencing a key encryption key in Key Vault.
sourceVaultrequiredidoptional - stringResource Id
imageoptionalurioptional - stringSpecifies the virtual hard disk's uri.
managedDiskoptionaldiskEncryptionSetoptionalidoptional - stringResource Id
idoptional - stringResource Id
storageAccountTypeoptional - stringSpecifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.
nameoptional - stringThe disk name.
osTypeoptional - stringThis property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: Windows Linux.
vhdoptionalurioptional - stringSpecifies the virtual hard disk's uri.
writeAcceleratorEnabledoptional - booleanSpecifies whether writeAccelerator should be enabled or disabled on the disk.
userDataoptional - stringUserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01
virtualMachineScaleSetoptionalidoptional - stringResource Id
tagsoptional - stringResource tags
typerequired - stringzonesoptional - arrayThe virtual machine zones.
Frequently asked questions
What is Azure Compute Linux Virtual Machine?
Azure Compute Linux Virtual Machine is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Compute Linux Virtual Machine?
For Terraform, the Heliotropo/casopractico2, toninoes/devopsunirp2 and etienne-plagnieux/Logskills_Terraform_Azure source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the maxskunkworks/TLG, maxskunkworks/TLG and maxskunkworks/TLG source code examples are useful. See the Azure Resource Manager Example section for further details.