Open omaraladin opened 1 year ago
Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)
Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)
Yeah it is similar to 72
you need to load the proxy details, in the code at runtime, because in proxy-environments if proxy is not loaded, Internet URLs will not be reached from the Request origin (the self-managed agent running your PRCreate task in my case)
how I think you could resolve it, as PS is used to code the task:
Add optional proxyParameter in the task, and if added, Load into defaultproxy environment variable on the Task Powershell runtime:
$HTTP_PROXY="http://proxy.company.com:8080"
$HTTPS_PROXY="http://proxy.company.com:8080"
Ref:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3#notes
Add optional proxyParameter in the task, and if added, load it as proxy-URL on your underlying PS Commands runtime:
example:
Invoke-WebRequest https://dev.azure.com -Proxy "http://proxy.company.com:8080" -ProxyCredential $ProxyCreds
Ref:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3#-proxy
Load Windows Machine-level Proxy settings, because that would be already configured on the machine-level and you can reuse that, but I am not sure how to load these variables, all what I know is that this command returns the default proxy settings on a machine-level, (see issue description for output example):
netsh winhttp show proxy
@omaraladin I using Invoke-RestMethod
so I think -Proxy
and -ProxyCredential
parameters will do the job, no?
yeah, should do the job, but make sure to add this flag only when the user specifies that a proxy is actually being used. see the first point in what I recommended here
Hi @omaraladin, is it similar to #72? If yes, can you provide me which details need to add? (I just not familiar with proxy...)
Yeah it is similar to 72
you need to load the proxy details, in the code at runtime, because in proxy-environments if proxy is not loaded, Internet URLs will not be reached from the Request origin (the self-managed agent running your PRCreate task in my case)
how I think you could resolve it, as PS is used to code the task:
- Add optional proxyParameter in the task, and if added, Load into defaultproxy environment variable on the Task Powershell runtime:
$HTTP_PROXY="http://proxy.company.com:8080"
$HTTPS_PROXY="http://proxy.company.com:8080"
Ref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3#notes- Add optional proxyParameter in the task, and if added, load it as proxy-URL on your underlying PS Commands runtime: example:
Invoke-WebRequest https://dev.azure.com -Proxy "http://proxy.company.com:8080" -ProxyCredential $ProxyCreds
Ref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3#-proxy- Load Windows Machine-level Proxy settings, because that would be already configured on the machine-level and you can reuse that, but I am not sure how to load these variables, all what I know is that this command returns the default proxy settings on a machine-level, (see issue description for output example):
netsh winhttp show proxy
Any progress or workarounds for this?
@omaraladin @spaasis can you try to run a simple Azure DevOps Rest API with Powershell and add the proxy param, for check if it will work?
Hi,
Description: when running the task in a self-managed agent that is behind a proxy, it throws an error:
##[error]The remote name could not be resolved: 'dev.azure.com'
Environment: OS: Windows Server 2019 Standard Proxxy settings: the domain "dev.azure.com" is actually bypassed through the proxy that is configured on the self-managed VM-level
>> netsh winhttp show proxy
`
Current WinHTTP proxy settings:How to reproduce: Include the task in a pipeline and specify demands to make the job run in a self-managed agent that is running behind a proxy
Possible fixes: Include an optional proxy-Parameter in the task that, if added, proxy-settings will be loaded in the task runtime