Monday, January 25, 2010
A few customers have asked how they can use tools like wazt, Windows Azure MMC, the Azure Cmdlets, etc. when they are behind proxies at work that require basic authentication. The tools themselves don't directly support this type of proxy. What we are doing is simply relying on the fact that the underlying HttpRequest object will pick up your IE's default proxy configuration. Most of the time, this just works.
However, if you are in an environment where you are prompted for your username and password, you might be on a basic auth proxy and the tools might not work. To work around this, you can actually implement a very simple proxy handler yourself and inject it into the application.
Here is one that I wrote to support wazt. To use this, add the following to your app.config and drop the output assembly from this project into your execution directory. Note, this would work with any tool in .NET that uses HttpWebRequest under the covers (like csmanage for instance).
<!-- basic auth proxy section declaration area-->
<!-- proxyHostAddress="Auto" : use Internet explorer configuration for name of the proxy -->
<configSections>
<sectionGroup name="proxyGroup">
<section name="basicProxy"
type="Proxy.Configuration.CustomProxySection, Proxy" />
</sectionGroup>
</configSections>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="false">
<module type="Proxy.CustomProxy, Proxy"/>
</defaultProxy>
</system.net>
<proxyGroup>
<basicProxy proxyHostAddress="Auto" proxyUserName="MyName" proxyUserPassword="MyPassword" />
</proxyGroup>
Download the source here.