I'm behind a corporate firewall and cannot connect using the command line interface, which probably doesn't get proxy information from the system configuration, but I cannot find a way to set the correct options.
Click Start, click Run, type cmd, and then click OK. At the command prompt, type netsh winhttp set proxy proxyservername:portnumber, and then press ENTER. In this command, replace proxyservername with the fully qualified domain name of the proxy server.
The Azure Command-Line Interface (CLI) is a cross-platform command-line tool to connect to Azure and execute administrative commands on Azure resources. It allows the execution of commands through a terminal using interactive command-line prompts or a script.
The environment variables mentioned in the other answer are part of the solution, so you do need to set them by running these commands before az login
. Note that (in my case, at least) both URLs start with http, not https.
In PowerShell:
$env:HTTP_PROXY="http://my-proxy-details"
$env:HTTPS_PROXY="http://my-proxy-details"
In cmd:
SET HTTP_PROXY http://my-proxy-details
SET HTTPS_PROXY http://my-proxy-details
Or, to set them permanently:
[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://my-proxy-details", "Machine")
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://my-proxy-details", "Machine")
If that fixes it for you, you can stop reading here. If not, and you see a certificate error, the extra step is to find the Azure CLI's private Python installation, and add your root certificate to its cacert.pem
files. While Python itself uses the Windows certificate store, some packages (notably certifi) do not.
You will need your proxy's root certificate in PEM format - that is, as base64 text rather than as a binary. It may well have the .cer
extension.
Find the site-packages folder inside Azure CLI's program folder. For me, it's C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages
. Search it for files named cacert.pem
. I found three of them. Copy the contents of your certificate and paste it at the bottom of each of these files. Save them and try again.
You could use HTTP_PROXY or HTTPS_PROXY environment variables to set a proxy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With