The following powershell snippet from the script works fine in a local machine:
$SharepointConnection = Connect-PnPOnline -Url $ConfigInfo.AProcessDef.ASharePointUrl.ToString().Trim() -Credential $SharepointCredential -ReturnConnection -Verbose -ErrorAction Stop
But it fails while running the very same snippet by a Azure DevOps build agent (self-hosted agent behind a proxy server) on a build VM machine. The build machine is behind a proxy and it is already configured. I already checked with InvokeWebRequest to reach organization's local intranet and internet and it worked fine well. I am getting the following exception with Connect-PnPOnline:
System.Net.WebException The remote name could not be resolved:
I logged into the vm machine , executed the snippet without any error. I can connect to the domainname.sharepoint.com.
Some hint is appreciated to address this issue.