Description
Description
here is the command cx running - Connect-AzAccount -ServicePrincipal -TenantId $TenantId -Credential $Credential -Subscription $subscriptionId -debug
Cx running on a machine (WS 2016) which are behind proxy.
Before running the above command, he is setting the proxy on PS 7.4 as below.
$proxyurl = 'proxyurl:8080'
$proxyuser = 'corpau\accountname'
# $proxyuser = 'accountname'
$proxypassword = 'password'
$proxy_ps7 = "http://$proxyuser" +":"+"$proxypassword"+"@"+"$proxyurl"
$env:HTTP_PROXY=$proxy_ps7
$env:HTTPS_PROXY=$proxy_ps7
It seems token retrieval is successful but it failed with the following error.
Connect-AzAccount: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (management.azure.com:443)
But same command works fine in PS 5.1 on another WS 2016 server behind the same proxy and same version of Az module. here is the sample script for setting proxy on PS 5.1.
$proxyurl = ''
$proxyuser = ''
$proxypassword = $password
$proxysecrepw = ConvertTo-SecureString -String $proxypassword -AsPlainText -Force
$proxycredential = New-Object System.Management.Automation.PSCredential($proxyuser, $proxysecrepw)
$proxy = New-Object System.Net.WebProxy($proxyurl)
$proxy.Credentials = $proxycredential
[System.Net.WebRequest]::defaultWebProxy = $proxy
From the debug log, i noticed the only different is .net version is different in both scenarios.
Please help how to resolve this issue in PS 7.4 with proxy.
Non-working scenario: AzAccountConnect_2.log
Working scenario: goodnode_ps5.1.txt
Script or Debug output
Environment data
PSVersion: 7.4.0
Module versions
Az.Accounts:4.0.1