So, this is a very weird issue and I can't figure it out... I'm following MS documentation on running the DevOps agent from a Docker container, and the following code is always failing.
Print-Header "1. Determining matching Azure Pipelines agent..."$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$(Get- Content ${Env:AZP_TOKEN_FILE})"))$package = Invoke-RestMethod -Headers @{Authorization = ("Basic $base64AuthInfo") } "$(${Env:AZP_URL})/_apis/distributedtask/packages/agent?platform=win-x64&`$top=1"$packageUrl = $package[0].Value.downloadUrlWrite-Host $packageUrlPrint-Header "2. Downloading Azure Pipelines agent..."$wc = New-Object System.Net.WebClient$wc.DownloadFile("$packageUrl", ".\agent.zip")
with the error
Exception calling "DownloadFile" with "2" argument(s): "The operation has timed out"At C:\azagent\agentGet.ps1:39 char:1$wc.DownloadFile("https://vstsagentpackage.azureedge.net/agent/3.232. ...CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : WebException
Here's why it's confusing...
- The same script works from the host computer (so it's not host-URL connectivity)
- The dockerfile has instructions, before running that code, to download java from the internet, which is also working, so it's not the process not having access to the internet
- Replacing the WebClient with an
Invoke-RestMethod
call just hangs forever, highlighting that it can't reach the URL