I want to be able to use a proxy server with Azure Python SDK NetworkManagementClient (NMC)
. I saw that the NMC
has a _client
attribute of type msrest.service_client
, which includes a config
attribute of type NetworkManagementClientConfiguration
which inherits from AzureConfiguration
, which itself has a proxies attribute of type msrest.pipeline.ClientProxies
.
Given the above it seems that configuring a proxy is possible, but I don't understand the proper way to set it up.
First, msrest is using requests, so I assume you read proxies documentation of requests. Note too that a requests.Session
object has a trust_env
attribute that is True
by default to read some env variables like HTTP_PROXY
.
The configuration of a client has a proxies
attribute, being as you mentioned a ClientProxies
class. This class has a proxies
dict attribute itself and a add
method to add in this dict. This class has also a use_env_settings
boolean attribute.
Assuming you have a client
variable instance of NetworkManagementClient
, so you can either:
Simply use HTTP_PROXY / HTTPS_PROXY. Note that you can disable env vars using
client.config.proxies.use_env_settings = False
This is just an alias to trust_env
of requests.
Define your own proxy:
client.config.proxies.add('http', 'http://example.org:8080')
The call will actually be equivalent to
session.get(url,proxies={'http': 'http://example.org:8080'})
(I own msrest at MS)