Accessing TFS from behind a proxy

2014-08-19

Lately I’ve been working with a client with very strict security rules. One of their policies is that all internet traffic runs through a proxy. This causes some problems when accessing a remote Team Foundation Server over HTTP.

One of the issues we ran into was using Excel to connect to Team Foundation Server to select queries and edit work items.

Excel gave the following error:

Excel error: Unable to connect to this Team Foundation Server

As you can see, at the bottom a 407 Proxy Authentication error is mentioned. This error happens because by default programs like Excel and Visual Studio are not configured to use your proxy settings when connecting to another application.

Proxy settings

Configuring a .NET application can be done by editing the app.config file. If you look at the MSDN documentation you’ll see that you can use the defaultProxy attribute:


<defaultProxy enabled="true|false" useDefaultCredentials="true|false"
    <bypasslist></bypasslist>
    <proxy></proxy>
    <module></module>
/>

The most important settings for our situation are the enabled and useDefaultCredentials attribute. Both should be set to true to make sure that Excel uses the proxy settings when connecting to TFS.

You can also specify a proxy element that specifies which proxy can be used:


<proxy usesystemdefault="True" bypassonlocal="True"/>

By setting usesystemdefault to True, your application will use the proxy settings that are configured in Internet Explorer. In corporate environments these settings are most often configured through a group policy so all computers have the correct settings.

Combining these will give you the following:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.net>
        <defaultProxy enabled="true"
                      useDefaultCredentials="true">
            <proxy usesystemdefault="True"
         bypassonlocal="True"/>
  </defaultProxy>
     </system.net>
</configuration>

Configuring Excel

When you have a 32bit version of Excel 2013 installed, your executable file can be found in:

C:\Program Files (x86)Microsoft OfficeOffice15 If you have a different version of Excel (like 2007), you have to look in your Microsoft Office folder for the correct version number.

To add the proxy configuration, add a new text file named: excel.app.config with the following content:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.net>
        <defaultProxy enabled="true"
                      useDefaultCredentials="true">
            <proxy usesystemdefault="True"
         bypassonlocal="True"/>
  </defaultProxy>
     </system.net>
</configuration>

Make sure you restart Excel so that it loads the new settings. And that’s all you have to do. After these settings, Excel will use your proxy configuration and allow you to connect to Team Foundation Server.

Questions? Feedback? Please leave a comment!