Installing the TFS OData service on your corporate TFS server

This blog post describes how to install and configure the OData TFS Service on your corporate TFS Server. I made this post because the TFS OData documentation does not really cover this topic very well. It covers the installation on Azure and on CodePlex.

A little background

My company Delta-N, built a nice Windows Phone application. The TFS Attacher. This application allows you to attach images to an existing work item on your TFS Server. For example when you draw pictures on a whiteboard during a stand up meeting, you can take a picture of the whiteboard and directly attach to the work item.

OData Service

The TFS Attacher works with the TFS OData Service. This service provides an elegant way to access and query TFS. Also some modify actions are enabled with this service. For example adding attachments to a work item.

You can find all about the OData Service on the blog of Brian Keller. You can download also from the Microsoft site.

Installing the Service

When you download the service and extract the bits, you’ll notice that it is not really an installable application, but more a set of source, docs and assemblies.

image

When I read the StartHere.htm or the word document inside the doc folder I got a little confused. I talked about azure and the examples were based on the CodePlex TFS.

I wanted to install the OData service on my TFS production Server. The document states that the Azure Tools for Visual Studio are needed to run the service. I do not want to pollute my production server with development tools.

So I tried some things from the documentation and tested some things and found a good work around to use the service on our corporate TFS.

Here are the steps I performed

Set up my Development environment

As I mentioned earlier, the OData download contains source code. The first thing I did was setting up my Development machine so that the OData service could be built and run. I followed the instructions that were in the document.

Most important thing is to run the setup.cmd. This install all the SDK’s and prerequisites. After installation open the ODataTFS.sln on your local computer and build solution.

Prepare Production Server

Now it’s time to prepare your production server to host the OData Service. It is not necessary that you host the OData Service on the TFS Production server. It can be any other server that can access your TFS Server but for now I chose to install it on the TFS Server.

First I made sure that my IIS had the necessary prerequisites.

  • Microsoft Visual Studio Team Explorer 2010
  • Microsoft .NET Framework 4
  • Internet Information Services 7, with the following features:
      • ASP.NET

        image

      • WCF HTTP Activation Feature Enabled

        image

I created a new directory called ODataTFS and created a new website pointing to this directory. Note that a new application pool is created.

image

  • Grant full access permissions to the IIS_ISUR user to the %programdata%\Microsoft\Team Foundation local folder.

    image

  • Grant read access permissions to the IIS_ISUR user to the ODataTFS folder
  • Open the advanced settings of the application pool and set the .Net framework version to v4.0

    image

  • Navigate to Authentication

    image

  • Disable all authentication methods
  • Enable Anonymous authentication
  • Start your application pool and website

Create deployment

Now it was time to create a deployable package which we can run on our production server. Surely, the nicest way to do this is to create an automated build on TFS to build your solution. However, in this case I will describe the easiest way to achieve this.

In the first step I opened the ODataTFS.sln and build it. Now I use the Publish Website option to create a deployable website.

image

image

The output in the directory is the set that you want to deploy. However, if you deploy this solution you will get an error message stating that some dll’s cannot be found.

This error is related to the fact that the Azure SDK is not and will not be installed on our production server. Luckily we can work around this.

Navigate to C:\Program Files\Windows Azure SDK\v1.5\bin\runtimes\base and copy the following files to the bin directory in your publish folder.

  • Microsoft.WindowsAzure.ServiceRuntime.dll
  • msshrtmi.dll (in subdir x86 or x64)

Now you need to make some modifications in the web.config. Again, the nice way is to do it in the automated build using Config Transformations but for now manually will do.

Remove the following section

   1: <system.diagnostics>

   2:   <trace>

   3:     <listeners>

   4:       <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">

   5:         <filter type="" />

   6:       </add>

   7:     </listeners>

   8:   </trace>

   9: </system.diagnostics>

set compilation debug to false

   1: <compilation debug="true" targetFramework="4.0" />

Change this setting to your own TFS url. (e.g. https://tfs.mycompany.com/tfs)

   1: <!-- TFS CODEPLEX SETTINGS -->

   2: <add key="ODataTFS.TfsServer" value="https://tfs.mycompany.com/tfs" />

NOTE: Make sure you run the OData service and your tfs service under https.

Deploy and Test OData Service

Copy the contents of your publish directory to your production server in the directory that you created there. Make sure the website is started.

Navigate to the website. If it is set up correctly, the page will display the following:

image

Now edit the url so you can access the OData Service. For example to retrieve projects you type.

{odataurl}/{CollectionName}/Projects –> https://odatatfs.mycompany.com/DefaultCollection/Projects

You will be asked for credentials. These are TFS credentials. If it is set up correctly, a list of projects will appear.

More examples are on the start page that shows when you access the url of your service.

Summary and Links

Advertisements

8 Responses to “Installing the TFS OData service on your corporate TFS server”

  1. Great article.

    If you get the error: “Could not load type System.ServiceModel.Activation.HttpModule” then this is because you turn on the feature “WCF HTTP Activation” in IIS after installing the .Net 4.0 framework.

    To solve this issue run the ASP.NET IIS Registration Tool: C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -iru

  2. Great post! Thanks for writing this up, Rene.

  3. Is this applicable for TFS 2015 also? Or is there something else for that?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: