using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$server = $Request.Query.Server
$port = $Request.Query.Port
try { (new-object Net.Sockets.TcpClient).Connect($server,$port) }
catch { $closed = $true }
if ($closed) { Write-host "nogo"; $body = "nogo for " + $server + ":" + $port }
Else { Write-host "yeah" ; $body = "yeah, clear paths to " + $server + ":" + $port }
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})