Microsoft.Compute/virtualMachines template reference

API Version: 2017-03-30

Template format

To create a Microsoft.Compute/virtualMachines resource, add the following JSON to the resources section of your template.

{
  "name": "string",
  "type": "Microsoft.Compute/virtualMachines",
  "apiVersion": "2017-03-30",
  "location": "string",
  "tags": {},
  "plan": {
    "name": "string",
    "publisher": "string",
    "product": "string",
    "promotionCode": "string"
  },
  "properties": {
    "hardwareProfile": {
      "vmSize": "string"
    },
    "storageProfile": {
      "imageReference": {
        "id": "string",
        "publisher": "string",
        "offer": "string",
        "sku": "string",
        "version": "string"
      },
      "osDisk": {
        "osType": "string",
        "encryptionSettings": {
          "diskEncryptionKey": {
            "secretUrl": "string",
            "sourceVault": {
              "id": "string"
            }
          },
          "keyEncryptionKey": {
            "keyUrl": "string",
            "sourceVault": {
              "id": "string"
            }
          },
          "enabled": boolean
        },
        "name": "string",
        "vhd": {
          "uri": "string"
        },
        "image": {
          "uri": "string"
        },
        "caching": "string",
        "createOption": "string",
        "diskSizeGB": "integer",
        "managedDisk": {
          "id": "string",
          "storageAccountType": "string"
        }
      },
      "dataDisks": [
        {
          "lun": "integer",
          "name": "string",
          "vhd": {
            "uri": "string"
          },
          "image": {
            "uri": "string"
          },
          "caching": "string",
          "createOption": "string",
          "diskSizeGB": "integer",
          "managedDisk": {
            "id": "string",
            "storageAccountType": "string"
          }
        }
      ]
    },
    "osProfile": {
      "computerName": "string",
      "adminUsername": "string",
      "adminPassword": "string",
      "customData": "string",
      "windowsConfiguration": {
        "provisionVMAgent": boolean,
        "enableAutomaticUpdates": boolean,
        "timeZone": "string",
        "additionalUnattendContent": [
          {
            "passName": "oobeSystem",
            "componentName": "Microsoft-Windows-Shell-Setup",
            "settingName": "string",
            "content": "string"
          }
        ],
        "winRM": {
          "listeners": [
            {
              "protocol": "string",
              "certificateUrl": "string"
            }
          ]
        }
      },
      "linuxConfiguration": {
        "disablePasswordAuthentication": boolean,
        "ssh": {
          "publicKeys": [
            {
              "path": "string",
              "keyData": "string"
            }
          ]
        }
      },
      "secrets": [
        {
          "sourceVault": {
            "id": "string"
          },
          "vaultCertificates": [
            {
              "certificateUrl": "string",
              "certificateStore": "string"
            }
          ]
        }
      ]
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "string",
          "properties": {
            "primary": boolean
          }
        }
      ]
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": boolean,
        "storageUri": "string"
      }
    },
    "availabilitySet": {
      "id": "string"
    },
    "licenseType": "string"
  },
  "identity": {
    "type": "SystemAssigned"
  },
  "resources": [
  ]
}

Property values

The following tables describe the values you need to set in the schema.

Microsoft.Compute/virtualMachines object

Name Type Required Value
name string Yes
type enum Yes Microsoft.Compute/virtualMachines
apiVersion enum Yes 2017-03-30
location string Yes Resource location
tags object No Resource tags
plan object No The purchase plan when deploying virtual machine from VM Marketplace images. - Plan object
properties object Yes VirtualMachineProperties object
identity object No The identity of the virtual machine, if configured. - VirtualMachineIdentity object
resources array No extensions

Plan object

Name Type Required Value
name string No The plan ID.
publisher string No The publisher ID.
product string No The offer ID.
promotionCode string No The promotion code.

VirtualMachineProperties object

Name Type Required Value
hardwareProfile object No The hardware profile. - HardwareProfile object
storageProfile object No The storage profile. - StorageProfile object
osProfile object No The OS profile. - OSProfile object
networkProfile object No The network profile. - NetworkProfile object
diagnosticsProfile object No The diagnostics profile. - DiagnosticsProfile object
availabilitySet object No The reference Id of the availability set to which the virtual machine belongs. - SubResource object
licenseType string No Specifies that the image or disk that is being used was licensed on-premises. This element is only used for images that contain the Windows Server operating system.

VirtualMachineIdentity object

Name Type Required Value
type enum No The type of identity used for the virtual machine. Currently, the only supported type is 'SystemAssigned', which implicitly creates an identity. - SystemAssigned

HardwareProfile object

Name Type Required Value
vmSize enum No The virtual machine size name. - Basic_A0, Basic_A1, Basic_A2, Basic_A3, Basic_A4, Standard_A0, Standard_A1, Standard_A2, Standard_A3, Standard_A4, Standard_A5, Standard_A6, Standard_A7, Standard_A8, Standard_A9, Standard_A10, Standard_A11, Standard_A1_v2, Standard_A2_v2, Standard_A4_v2, Standard_A8_v2, Standard_A2m_v2, Standard_A4m_v2, Standard_A8m_v2, Standard_D1, Standard_D2, Standard_D3, Standard_D4, Standard_D11, Standard_D12, Standard_D13, Standard_D14, Standard_D1_v2, Standard_D2_v2, Standard_D3_v2, Standard_D4_v2, Standard_D5_v2, Standard_D11_v2, Standard_D12_v2, Standard_D13_v2, Standard_D14_v2, Standard_D15_v2, Standard_DS1, Standard_DS2, Standard_DS3, Standard_DS4, Standard_DS11, Standard_DS12, Standard_DS13, Standard_DS14, Standard_DS1_v2, Standard_DS2_v2, Standard_DS3_v2, Standard_DS4_v2, Standard_DS5_v2, Standard_DS11_v2, Standard_DS12_v2, Standard_DS13_v2, Standard_DS14_v2, Standard_DS15_v2, Standard_F1, Standard_F2, Standard_F4, Standard_F8, Standard_F16, Standard_F1s, Standard_F2s, Standard_F4s, Standard_F8s, Standard_F16s, Standard_G1, Standard_G2, Standard_G3, Standard_G4, Standard_G5, Standard_GS1, Standard_GS2, Standard_GS3, Standard_GS4, Standard_GS5, Standard_H8, Standard_H16, Standard_H8m, Standard_H16m, Standard_H16r, Standard_H16mr, Standard_L4s, Standard_L8s, Standard_L16s, Standard_L32s, Standard_NC6, Standard_NC12, Standard_NC24, Standard_NC24r, Standard_NV6, Standard_NV12, Standard_NV24

StorageProfile object

Name Type Required Value
imageReference object No The image reference. - ImageReference object
osDisk object No The OS disk. - OSDisk object
dataDisks array No The data disks. - DataDisk object

OSProfile object

Name Type Required Value
computerName string No Specifies the host OS name of the virtual machine.
adminUsername string No Specifies the name of the administrator account.
adminPassword string No Specifies the password of the administrator account.
customData string No Specifies 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
windowsConfiguration object No The Windows configuration of the OS profile. - WindowsConfiguration object
linuxConfiguration object No The Linux configuration of the OS profile. - LinuxConfiguration object
secrets array No The list of certificates for addition to the VM. - VaultSecretGroup object

NetworkProfile object

Name Type Required Value
networkInterfaces array No Specifies the list of resource IDs for the network interfaces associated with the virtual machine. - NetworkInterfaceReference object

DiagnosticsProfile object

Name Type Required Value
bootDiagnostics object No Boot Diagnostics is a debugging feature which allows the user to view console output and/or a screenshot of the virtual machine from the hypervisor. - BootDiagnostics object

SubResource object

Name Type Required Value
id string No Resource Id

ImageReference object

Name Type Required Value
id string No Resource Id
publisher string No The image publisher.
offer string No The image offer.
sku string No The image SKU.
version string No The image version. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor and Build are decimal numbers. Specify 'latest' to use the latest version of the image.

OSDisk object

Name Type Required Value
osType enum No The Operating System type. - Windows or Linux
encryptionSettings object No The disk encryption settings. - DiskEncryptionSettings object
name string No The disk name.
vhd object No The virtual hard disk. - VirtualHardDisk object
image object No The source user image virtual hard disk. The virtual hard disk will be copied before using it to attach to the virtual machine. If SourceImage is provided, the destination virtual hard disk must not exist. - VirtualHardDisk object
caching enum No The caching type. - None, ReadOnly, ReadWrite
createOption enum Yes The create option. - fromImage, empty, attach
diskSizeGB integer No The initial disk size, in GB, for blank data disks, and the new desired size for resizing existing OS and data disks.
managedDisk object No The managed disk parameters. - ManagedDiskParameters object

DataDisk object

Name Type Required Value
lun integer Yes The logical unit number.
name string No The disk name.
vhd object No The virtual hard disk. - VirtualHardDisk object
image object No The source user image virtual hard disk. This virtual hard disk will be copied before using it to attach to the virtual machine. If SourceImage is provided, the destination virtual hard disk must not exist. - VirtualHardDisk object
caching enum No The caching type. - None, ReadOnly, ReadWrite
createOption enum Yes The create option. - fromImage, empty, attach
diskSizeGB integer No The initial disk size in GB for blank data disks, and the new desired size for resizing existing OS and data disks.
managedDisk object No The managed disk parameters. - ManagedDiskParameters object

WindowsConfiguration object

Name Type Required Value
provisionVMAgent boolean No Indicates whether the virtual machine agent should be provisioned on the Virtual Machine. If not specified, then the default behavior is to set it to true.
enableAutomaticUpdates boolean No Indicates whether Windows updates are automatically installed on the VM.
timeZone string No The time zone of the VM
additionalUnattendContent array No Additional base-64 encoded XML formatted information that can be included in the Unattend.xml file. - AdditionalUnattendContent object
winRM object No The Windows Remote Management configuration of the VM - WinRMConfiguration object

LinuxConfiguration object

Name Type Required Value
disablePasswordAuthentication boolean No Specifies whether password authentication should be disabled.
ssh object No The SSH configuration for linux VMs. - SshConfiguration object

VaultSecretGroup object

Name Type Required Value
sourceVault object No The Relative URL of the Key Vault containing all of the certificates in VaultCertificates. - SubResource object
vaultCertificates array No The list of key vault references in SourceVault which contain certificates. - VaultCertificate object

NetworkInterfaceReference object

Name Type Required Value
id string No Resource Id
properties object No NetworkInterfaceReferenceProperties object

BootDiagnostics object

Name Type Required Value
enabled boolean No Whether boot diagnostics should be enabled on the Virtual Machine.
storageUri string No URI of the storage account to use for placing the console output and screenshot.

DiskEncryptionSettings object

Name Type Required Value
diskEncryptionKey object No The disk encryption key which is a Key Vault Secret. - KeyVaultSecretReference object
keyEncryptionKey object No The key encryption key which is Key Vault Key. - KeyVaultKeyReference object
enabled boolean No Specifies whether disk encryption should be enabled on the virtual machine.

VirtualHardDisk object

Name Type Required Value
uri string No The virtual hard disk's URI. Must be a valid URI to a virtual hard disk.

ManagedDiskParameters object

Name Type Required Value
id string No Resource Id
storageAccountType enum No The Storage Account type. - Standard_LRS or Premium_LRS

AdditionalUnattendContent object

Name Type Required Value
passName enum No The pass name. Currently, the only allowable value is oobeSystem. - oobeSystem
componentName enum No The component name. Currently, the only allowable value is Microsoft-Windows-Shell-Setup. - Microsoft-Windows-Shell-Setup
settingName enum No Setting name (e.g. FirstLogonCommands, AutoLogon ). - AutoLogon or FirstLogonCommands
content string No XML formatted content that is added to the unattend.xml file in the specified pass and component. The XML must be less than 4 KB and must include the root element for the setting or feature that is being inserted.

WinRMConfiguration object

Name Type Required Value
listeners array No The list of Windows Remote Management listeners - WinRMListener object

SshConfiguration object

Name Type Required Value
publicKeys array No The list of SSH public keys used to authenticate with linux based VMs. - SshPublicKey object

VaultCertificate object

Name Type Required Value
certificateUrl string No The URL referencing a secret in a Key Vault which contains a properly formatted certificate.
certificateStore string No The Certificate store in LocalMachine to add the certificate to on Windows, leave empty on Linux.

NetworkInterfaceReferenceProperties object

Name Type Required Value
primary boolean No Specifies the primary network interface in case the virtual machine has more than 1 network interface.

KeyVaultSecretReference object

Name Type Required Value
secretUrl string Yes The URL referencing a secret in a Key Vault.
sourceVault object Yes The relative URL of the Key Vault containing the secret. - SubResource object

KeyVaultKeyReference object

Name Type Required Value
keyUrl string Yes The URL referencing a key in a Key Vault.
sourceVault object Yes The relative URL of the Key Vault containing the key. - SubResource object

WinRMListener object

Name Type Required Value
protocol enum No The Protocol used by the WinRM listener. Http and Https are supported. - Http or Https
certificateUrl string No The Certificate URL in KMS for Https listeners. Should be null for Http listeners.

SshPublicKey object

Name Type Required Value
path string No Specifies 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.
keyData string No Certificate public key used to authenticate to the VM through SSH. The certificate must be in Pem format with or without headers.

Quickstart templates

For example templates, see Compute templates.