Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. At C:BizTalkApplicationsMonitorMonitor_BizTalk_DiskSpaceStorage_with_Flow.ps1:77 char:1 + Invoke-WebRequest -Uri ‘https://{URI}.logic.azure.com:44 … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Cause
I had already experienced something similar when communicating with Logic Apps from the BizTalk Server Logic App adapter. However, I had already forgotten about it.
But in fact, the essence of this error and the one I got with the BizTalk adapter is the same.
The Logic App Request trigger supports only Transport Layer Security (TLS) 1.2 for incoming calls. Outgoing calls continue to support TLS 1.0, 1.1, and 1.2.
Solution
The solution was, and is, very simple, we just need to enforce PowerShell to use TLS 1.2. This can be done using this PowerShell one-liner: