title: create azure vm from image using terraform
body: <p>I have taken reference of github code.Please find below URL</p>
  
  <p><a href="https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/vm-from-managed-image" rel="nofollow noreferrer">https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/vm-from-managed-image</a></p>
  
  <p>I modified the scripts and executed terraform init. I received below error.</p>
  
  <p><strong>Error reading config for azurerm_network_interface[main]: parse error at 1:18: expected ")" but found "."[0m</strong></p>
  
  <p>My Script :</p>
  
  <pre><code>    # Configure the Microsoft Azure Provider
  provider "azurerm" {
      subscription_id = "xxxxxxxx"
      client_id       = "xxxxxxxx"
      client_secret   = "xxxxxxxx"
      tenant_id       = "xxxxxxxx"
  }
  
  # Locate the existing custom/golden image
  data "azurerm_image" "search" {
    name                = "AZLXSPTDEVOPS01_Image"
    resource_group_name = "RG-PLATFORM"
  }
  
  output "image_id" {
    value = "/subscriptions/4f5c9f2a-3584-4bbd-a26e-bbf69ffbfbe6/resourceGroups/RG-EASTUS-SPT-PLATFORM/providers/Microsoft.Compute/images/AZLXSPTDEVOPS01_Image"
  }
  
  # Create a Resource Group for the new Virtual Machine.
  resource "azurerm_resource_group" "main" {
    name     = "RG-TEST"
    location = "eastus"
  }
  
  # Create a Virtual Network within the Resource Group
  resource "azurerm_virtual_network" "main" {
    name                = "RG-Vnet"
    address_space       = ["10.100.0.0/16"]
    resource_group_name = "${azurerm_resource_group.main.name}"
    location            = "${azurerm_resource_group.main.location}"
  }
  
  # Create a Subnet within the Virtual Network
  resource "azurerm_subnet" "internal" {
    name                 = "RG-Terraform-snet-in"
    virtual_network_name = "${azurerm_virtual_network.main.name}"
    resource_group_name  = "${azurerm_resource_group.main.name}"
    address_prefix       = "10.100.2.0/24"
  }
  
  # Create a Network Security Group with some rules
  resource "azurerm_network_security_group" "main" {
    name                = "RG-QA-Test-Web-NSG"
    location            = "${azurerm_resource_group.main.location}"
    resource_group_name = "${azurerm_resource_group.main.name}"
  
    security_rule {
      name                       = "allow_SSH"
      description                = "Allow SSH access"
      priority                   = 100
      direction                  = "Inbound"
      access                     = "Allow"
      protocol                   = "Tcp"
      source_port_range          = "*"
      destination_port_range     = "22"
      source_address_prefix      = "*"
      destination_address_prefix = "*"
    }
  }
  
  # Create a network interface for VMs and attach the PIP and the NSG
  resource "azurerm_network_interface" "main" {
    name                      = "myNIC"
    location                  = "${azurerm_resource_group.main.location}"
    resource_group_name       = "${azurerm_resource_group.main.name}"
    network_security_group_id = "${azurerm_network_security_group.main.id}"
  
    ip_configuration {
      name                          = "primary"
      subnet_id                     = "${azurerm_subnet.internal.id}"
      private_ip_address_allocation = "static"
      private_ip_address            = "${cidrhost("10.100.1.8/24", 4)}"
    }
  }
  
  # Create a new Virtual Machine based on the Golden Image
  resource "azurerm_virtual_machine" "vm" {
    name                             = "AZLXSPTDEVOPS01"
    location                         = "${azurerm_resource_group.main.location}"
    resource_group_name              = "${azurerm_resource_group.main.name}"
    network_interface_ids            = ["${azurerm_network_interface.main.id}"]
    vm_size                          = "Standard_DS12_v2"
    delete_os_disk_on_termination    = true
    delete_data_disks_on_termination = true
  
    storage_image_reference {
      id = "${data.azurerm_image.search.id}"
    }
  
    storage_os_disk {
      name              = "AZLXSPTDEVOPS01-OS"
      caching           = "ReadWrite"
      create_option     = "FromImage"
      managed_disk_type = "Standard_LRS"
  }
  
    os_profile {
      computer_name  = "APPVM"
      admin_username = "admin"
      admin_password = "admin#2019"
    }
  
    os_profile_linux_config {
      disable_password_authentication = false
    }
  }
  </code></pre>