diff --git a/builtin/providers/azurerm/resource_arm_virtual_machine.go b/builtin/providers/azurerm/resource_arm_virtual_machine.go index e2b26584d5..b2121df8a9 100644 --- a/builtin/providers/azurerm/resource_arm_virtual_machine.go +++ b/builtin/providers/azurerm/resource_arm_virtual_machine.go @@ -214,8 +214,8 @@ func resourceArmVirtualMachine() *schema.Resource { Schema: map[string]*schema.Schema{ "computer_name": { Type: schema.TypeString, - Optional: true, ForceNew: true, + Required: true, }, "admin_username": { @@ -847,9 +847,11 @@ func expandAzureRmVirtualMachineOsProfile(d *schema.ResourceData) (*compute.OSPr adminUsername := osProfile["admin_username"].(string) adminPassword := osProfile["admin_password"].(string) + computerName := osProfile["computer_name"].(string) profile := &compute.OSProfile{ AdminUsername: &adminUsername, + ComputerName: &computerName, } if adminPassword != "" { @@ -883,9 +885,6 @@ func expandAzureRmVirtualMachineOsProfile(d *schema.ResourceData) (*compute.OSPr } } - if v := osProfile["computer_name"].(string); v != "" { - profile.ComputerName = &v - } if v := osProfile["custom_data"].(string); v != "" { profile.CustomData = &v } diff --git a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown index 2938c0a135..7f719337ca 100644 --- a/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/azurerm/r/virtual_machine.html.markdown @@ -253,7 +253,7 @@ For more information on the different example configurations, please check out t `os_profile` supports the following: -* `computer_name` - (Optional) Specifies the name of the virtual machine. +* `computer_name` - (Required) Specifies the name of the virtual machine. * `admin_username` - (Required) Specifies the name of the administrator account. * `admin_password` - (Required) Specifies the password of the administrator account. * `custom_data` - (Optional) 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.