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.downloadUrl
Write-Host $packageUrl
Print-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: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : WebException
Here's why it's confusing...
Invoke-RestMethod
call just hangs forever, highlighting that it can't reach the URLNevermind... the issue ended up being the VPN on the host, which is weird because the host can execute the script fine, but the request is blocked when it's coming from the container.
Disconnecting from the VPN allowed both scripts (host and container) to work.