Proxy servers are a very common thing in a lot of enterprises. They are used so that people cannot directly access the internet, and additional management capabilities to the flow (logging, authentication, …). Now that sounds very dandy, though what about those non-browser-based tools? How can we ensure that tools like Azure CLI, Azure Powershell & AzCopy work with our “beloved” enterprise proxy? That’ll be the topic for today!
What will we be doing today? I’ve setup a proxy server in my own lab… Basically deployed a Squid proxy by means of a container.
Next up, I’m going to use the three earlier mentioned tools on both Linux (WSL) & Windows, and see what needs to be done to get things working. In the following screenshots you’ll typically see a “split screen”, where left is a “tcpdump” on the box running the proxy server and right will be the commands on the box running the tools. If you see a lot of mumbo jumbo (network packets) on the left, that’ll mean that the proxy server was being used. Ready?!? Cool, let’s go!
On the Linux side, we’ll start off by leveraging the “http_proxy” & “https_proxy” environment variables. How to set those?
- export http_proxy = “host:port”
- export https_proxy = “host:port”
Now let’s test the Azure CLI by doing “az login –use-device-code”
Boom! It’s using the proxy as part of the typical default linux experience for setting a web proxy. Now let’s remove the https_proxy value, and see what happens…
It doesn’t use the proxy anymore… So Azure CLI is leveraging the “https_proxy” value! Now let’s try the same flow with AzCopy!
Both variables set, and the proxy is being used. Now let’s remove the “https_proxy” one, and … AzCopy still works.
Let’s remove the “http_proxy” one, and AzCopy doesn’t use the proxy anymore.
- Azure CLI uses the default “https_proxy” environment variable, where AzCopy uses the “http_proxy” one.
Now let’s try to same with windows. I’ve set the “HTTP_PROXY” variable, and… nothing
Let’s add the HTTP_PROXY one… nope!
Now let’s add the windows proxy…
And try the Azure Powershell part again…
And we are in business! Same thing for the Azure CLI
And what about AzCopy? Hmm… Nope!
Let’s try to set the system (!) environment variable “https_proxy” for this…
And yes… that works!
- Use the system wide proxy setting of windows for the Azure CLI & Azure Powershell.
- Use the “https_proxy” system wide environment variable for AzCopy
Proxy configurations are always… “fun”… *ahum*. Though I hope this post helps you in setting up your environment so that your favorite tools are still working as you would expect them to do!
2 thoughts on “What the proxy?!? How to use a proxy with the typical Azure tools…”
Thanks Karim very interesting !
You are welcome! 😉