"Invoke-WebRequest : The underlying connection was closed: An unexpected error

Guduru, Sravan Kumar 21 Reputation points
2020-09-14T22:11:23.827+00:00

Hi , I have tried below different ways to download azcopy using custom script extension

$AllProtocols = [System.Net.SecurityProtocolType]'Tls12'

[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

[Net.ServicePointManager]::SecurityProtocol +='tls12'

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12

Invoke-WebRequest -Uri https://aka.ms/downloadazcopy-v10-windows -OutFile $env:C:\temp\azcopy.zip

when I run my custom script extension , I am getting below error

"Invoke-WebRequest : The underlying connection was closed: An unexpected error

Any help on how to resolve it ?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,158 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 43,801 Reputation points Microsoft Employee
    2020-09-15T04:48:57.327+00:00

    @Guduru, Sravan Kumar Based on the error message there is a similar thread discussion in SO forum, please try the troubleshooting mentioned over-there and if the issue still persists, can you please the share the complete script hiding the PI data.

    Azure Storage (including Azcopy) currently supports three versions of the TLS protocol: 1.0, 1.1, and 1.2. Azure Storage uses TLS 1.2 on public HTTPS endpoints, but TLS 1.0 and TLS 1.1 are still supported for backward compatibility.

    For more information, please refer to this article: https://learn.microsoft.com/en-us/azure/storage/common/transport-layer-security-configure-minimum-version?tabs=portal

    Hope this helps! Kindly let us know if the above helps or you need further assistance on this issue.

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments