@Peizhu S Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I understand that you are encountering the error
Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required') while using the Azure CLI.
To make the Azure CLI work behind a proxy there are a few steps to be considered.
To configure a proxy globally for your script or app, define
HTTPS_PROXY environment variables with the server URL. These variables work with any version of the Azure libraries. Note that
HTTPS_PROXY doesn't mean
HTTPS proxy, but the proxy for
If the proxies require authentication, The format of the
HTTPS_PROXY environment variables should include the authentication, such as
# Non-authenticated HTTP proxy for HTTPS requests: export HTTPS_PROXY=http://10.10.1.10:1180 # Authenticated HTTP proxy for HTTPS requests: export HTTPS_PROXY=http://username:firstname.lastname@example.org:1180 # Non-authenticated HTTP proxy for HTTP requests: export HTTP_PROXY=http://10.10.1.10:1180 # Authenticated HTTP proxy for HTTP requests: export HTTP_PROXY=http://username:email@example.com:1180
If the above steps doesn't help you need to raise the issue in the Azure CLI GitHub repo here:
https://github.com/Azure/azure-cli/issues . The AzCLI experts will be able to assist you further.
Hope this helps.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.