diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown
index 0213d772c971..cf4019d33250 100644
--- a/website/docs/r/virtual_machine.html.markdown
+++ b/website/docs/r/virtual_machine.html.markdown
@@ -10,7 +10,7 @@ description: |-
Create a virtual machine.
-## Example Usage with Managed Disks (Recommended)
+## Example Usage with Managed Disks and Azure Platform Images (Recommended)
```hcl
resource "azurerm_resource_group" "test" {
@@ -113,6 +113,116 @@ resource "azurerm_virtual_machine" "test" {
}
```
+## Example Usage with Managed Disks and Custom Images (Recommended)
+
+```hcl
+#Assume that custom image has been already created in the 'customimage' resource group
+data "azurerm_resource_group" "image" {
+ name = "customimage"
+}
+
+data "azurerm_image" "image" {
+ name = "myCustomImage"
+ resource_group_name = "${data.azurerm_resource_group.image.name}"
+}
+
+resource "azurerm_resource_group" "test" {
+ name = "acctestrg"
+ location = "West US 2"
+}
+
+resource "azurerm_virtual_network" "test" {
+ name = "acctvn"
+ address_space = ["10.0.0.0/16"]
+ location = "${azurerm_resource_group.test.location}"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+}
+
+resource "azurerm_subnet" "test" {
+ name = "acctsub"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ virtual_network_name = "${azurerm_virtual_network.test.name}"
+ address_prefix = "10.0.2.0/24"
+}
+
+resource "azurerm_network_interface" "test" {
+ name = "acctni"
+ location = "${azurerm_resource_group.test.location}"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+
+ ip_configuration {
+ name = "testconfiguration1"
+ subnet_id = "${azurerm_subnet.test.id}"
+ private_ip_address_allocation = "dynamic"
+ }
+}
+
+resource "azurerm_managed_disk" "test" {
+ name = "datadisk_existing"
+ location = "${azurerm_resource_group.test.location}"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ storage_account_type = "Standard_LRS"
+ create_option = "Empty"
+ disk_size_gb = "1023"
+}
+
+resource "azurerm_virtual_machine" "test" {
+ name = "acctvm"
+ location = "${azurerm_resource_group.test.location}"
+ resource_group_name = "${azurerm_resource_group.test.name}"
+ network_interface_ids = ["${azurerm_network_interface.test.id}"]
+ vm_size = "Standard_DS1_v2"
+
+ # Uncomment this line to delete the OS disk automatically when deleting the VM
+ # delete_os_disk_on_termination = true
+
+ # Uncomment this line to delete the data disks automatically when deleting the VM
+ # delete_data_disks_on_termination = true
+
+ storage_profile_image_reference {
+ id="${data.azurerm_image.image.id}"
+ }
+
+ storage_os_disk {
+ name = "myosdisk1"
+ caching = "ReadWrite"
+ create_option = "FromImage"
+ managed_disk_type = "Standard_LRS"
+ }
+
+ # Optional data disks
+ storage_data_disk {
+ name = "datadisk_new"
+ managed_disk_type = "Standard_LRS"
+ create_option = "Empty"
+ lun = 0
+ disk_size_gb = "1023"
+ }
+
+ storage_data_disk {
+ name = "${azurerm_managed_disk.test.name}"
+ managed_disk_id = "${azurerm_managed_disk.test.id}"
+ create_option = "Attach"
+ lun = 1
+ disk_size_gb = "${azurerm_managed_disk.test.disk_size_gb}"
+ }
+
+ os_profile {
+ computer_name = "hostname"
+ admin_username = "testadmin"
+ admin_password = "Password1234!"
+ }
+
+ os_profile_linux_config {
+ disable_password_authentication = false
+ }
+
+ tags {
+ environment = "staging"
+ }
+}
+```
+
## Example Usage with Unmanaged Disks
```hcl