Hi,
I have a PowerShell Azure function (Timer triggered) which calls an external API via Invoke-RestMethod.
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic $secret")
$headers.Add("Content-Type", "application/json; charset=utf-8")
$headers.Add("Cookie", "......")
$roleurl = "https://myurl.domain.com/rest/api//$($project.key)/role"
$roles = Invoke-RestMethod $roleurl -Method 'GET' -Headers $headers
Always when I trigger this to run in the Azure Portal, I am getting
2024-08-14T14:43:48Z [Error] ERROR: No such host is known. (myurl.domain.com:443) Exception : Type : System.Net.Http.HttpRequestException TargetSite : Name : MoveNext DeclaringType : System.Net.Http.HttpConnectionPool+<ConnectToTcpHostAsync>d__98, System.Net.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a MemberType : Method Module : System.Net.Http.dll Message : No such host is known. (myurl.domain.com:443) InnerException : Type : System.Net.Sockets.SocketException Message : No such host is known. SocketErrorCode : HostNotFound ErrorCode : 11001 NativeErrorCode : 11001 TargetSite : Name : ThrowException DeclaringType : System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs, System.Net.Sockets, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a MemberType : Method Module : System.Net.Sockets.dll Source : System.Net.Sockets HResult : -2147467259 StackTrace : at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) Source : System.Net.Http HResult : -2147467259 StackTrace : at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(HttpClient client, HttpRequestMessage request, Boolean keepAuthorization) at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
I am able to run the same e.g. on my local machine succesfully.
Did I missed anything to configure or import?