title: Terraform provisioner cannot winrm to new built Windows VM on Azure
body: <p>I'm trying to provision a windows VM on Azure with Terraform and bootstrap it in the same time. The way I can think of is terraform provisioner. For testing purpose, I wrote the provisioner like this:</p>
  
  <pre><code>provisioner "remote-exec" {
      inline = [
        "md c:/terraform",
      ]
      connection {
        type     = "winrm"
        host   = "${azurerm_network_interface.vmstamp.private_ip_address}"
        user     = "${var.admin_username}"
        password = "${var.admin_password}"
        https    = false
        insecure = true
        timeout = "1m"
      }
  }
  </code></pre>
  
  <p>The template successfully provisioned the VM, but yield an error when trying to connect the VM with WinRM. </p>
  
  <pre><code>azurerm_virtual_machine.vmstamp: Still creating... (5m50s elapsed)
  azurerm_virtual_machine.vmstamp (remote-exec): Connecting to remote host via WinRM...
  azurerm_virtual_machine.vmstamp (remote-exec):   Host: 10.237.249.146
  azurerm_virtual_machine.vmstamp (remote-exec):   Port: 5985
  azurerm_virtual_machine.vmstamp (remote-exec):   User: azadmin
  azurerm_virtual_machine.vmstamp (remote-exec):   Password: true
  azurerm_virtual_machine.vmstamp (remote-exec):   HTTPS: true
  azurerm_virtual_machine.vmstamp (remote-exec):   Insecure: true
  azurerm_virtual_machine.vmstamp (remote-exec):   NTLM: false
  azurerm_virtual_machine.vmstamp (remote-exec):   CACert: false
  azurerm_virtual_machine.vmstamp: Still creating... (6m0s elapsed)
  
  Error: Error applying plan:
  
  1 error(s) occurred:
  
  * azurerm_virtual_machine.vmstamp: timeout - last error: unknown error Post https://10.237.249.146:5985/wsman: dial tcp 10.237.249.146:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  </code></pre>
  
  <p>Several things I have tried:</p>
  
  <p>1) Was thinking about firewall issue. But packer can launch connect to the new built windows VM on the same laptop with below code:</p>
  
  <pre><code>"communicator": "winrm",
  "winrm_use_ssl": "true",
  "winrm_insecure": "true",
  "winrm_timeout": "3m",
  "winrm_username": "packer",
  </code></pre>
  
  <p>2) Tried <code>https=true</code> and <code>https=false</code>, both failed.</p>
  
  <p>3) Tried <code>use_ntlm=true</code> and <code>use_ntlm=false</code>, both failed.</p>
  
  <p>4) Tried <code>port=5985</code> and <code>port=5986</code>, both failed. 5986 is actually not listening in a new windows VM from market image.</p>
  
  <p>what's the correct configuration for terraform provisioner?</p>