Connection timeout during file provision to azurerm vm

痞子三分冷 提交于 2019-12-14 03:09:30

问题


I am getting below timeout message once trying to provision file to an azure RM VM .

unknown error Post http://terraform.eastus.cloudapp.azure.com:3389/wsman: read tcp 192.168.0.4:59745->52.224.162.240:3389: wsarecv: An existing connection was forcibly closed by the remote host.

I am trying file provision and the VM already there and no need to create it. I only need to copy a text file to an existing VM using below config.

provider "azurerm"
{
}
resource "null_resource" "test"
{

provisioner "file" 
{
        connection 
        {
            type = "winrm"
            user = ""
            password = ""
            host="terraform.eastus.cloudapp.azure.com"
            port="3389"
            timeout = "20m"
        }
    source = "D:\\jaish\\output.txt"
    destination = "D:\\output.txt"

}
}

回答1:


You could check official document(Provisioner Connections) in this link.

Additional arguments only supported by the winrm connection type:

https - Set to true to connect using HTTPS instead of HTTP.

Now, you use connection type is winrm, so you need open port 5986 on VM's firewall and Azure NSG. You also need create a self-signed certificate. You could check this blog to do this.


Another solution, you could use Azure Custom Script to do this. You could create a script to download file from Azure Storage account or github.

Using terraform to do this, you could check this answer.




回答2:


I have not tried this approach before but the first thing that draws my attention is that you are using a type of winrm with a port of 3389. 3389 is used for RDP and the default winrm ports are 5985 (HTTP) and 5986 (HTTPS).



来源:https://stackoverflow.com/questions/48882420/connection-timeout-during-file-provision-to-azurerm-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!