Subscribe to our blog by signing up for the naked Agility newsletter, or by subscribing to the RSS feed.

Getting a service account for VSO with TFS Service Credential Viewer

Have you tried to get a service account for Visual Studio Online (VSO)? Did you know that you can use the TFS Service Credential Viewer to get it.

When you join a local or azure build server to your VSO account you are asked to log in with an account that is an administrator to get credentials. However it cant continue to use your credentials as your Microsoft ID token expires after 2 days and you would have to login again. Not a good experience. However there is a little bit of code that the build server uses to get a basic service username and password that it uses instead. I have used this to create unit tests that hit the TFS API’s in VSO as well as do all sorts of automated tasks that I need.

I created the TFS Service Credential Viewer when the service was still in Preview but it is no less required now. Its your gateway to automation with VSO.

Download TFS Service Credential Viewer

The following prerequisites are required:

  • Team Explorer 2013 Visual Studio 11 (any version)
  • .NET 4.5

If these components are already installed, you can launch the application now. Otherwise, click install below to install the prerequisites and run the application.

install or launch via clickonce

How it works

Once you have authenticated as a TFS Collection Administrator using your Microsoft ID to your hosted VSO instance we use the Access Control Service to provision a service identity that you can use for unattended connections to VSO.

SNAGHTML85af783
Figure: A quick #1, #2 to get your credentials

http://youtu.be/Fkn6V0_zz28
Video: How to get your credentials

Troubleshooting

If you are using Windows 8 you will not get an automatic launch of the application due to an extra security check called Smart Screen for applications that come from the internet.

  1. Click or Press “Start” and Scroll all the way to the right
  2. Select the TFS Service Credential Viewer
  3. When the security dialog pops up click “More Info”

    image
    Figure: Select More Info

  4. Click “Run anyway” to launch the application and add it to the safe list

    image
    Figure;

  5. Done

If you encounter an exception when clicking “Connect” the most likely cause if that you do not have Team Explorer 2013 installed (it should also work with 2012).

  • Pingback: Dew Drop – June 19, 2014 (#1800) | Morning Dew()

  • Pingback: Ranger Flash – June 2014 … gearing up for another adventurous year - Willy's Reflections - Site Home - MSDN Blogs()

  • Philip Street

    Hi Martin

    I’m trying to use your TFS Service Credential Viewer app, but it crashes whenever I click the Connect button; a System.IO.FileNotFoundException exception is written to the Eventlog.

    I have Visual Studio 2013 with Update 4 installed, is that good enough?

    Thanks.

    Phil

    • @philipstreet:disqus the app is built for Visual Studio 2015.

      • Hans

        Which version is it? You only spoke about VS 2012 before, but I also have trouble getting running with those. Now you mention VS 2015, but there is not team explorer for this only yet? I have tried VS2012,VS2013 and VS2015 preview but the Credential Viewer always closes without any notice. Any hints?

        • Hi Martin,

          Just launched the tool on a new VS15 image on Azure and it crashed when clicking the connect button.

          An unhandled exception of type ‘System.IO.FileNotFoundException’ occurred in GalaSoft.MvvmLight.WPF4.dll

          • Do you have a 32 bit system? Or 64? I am having trouble with the 2015 object model…

          • I’m using the VS2015 image as prepared by MS in the Azure Gallery. It is a Windows Server 2012 R2 (so 64-bit).

          • Philip Street

            OK, I’ve fixed the problem.

            I ran the app again but attached VS2013 debugger to see what was causing the Exception;

            System.IO.FileNotFoundException was unhandled

            Message: An unhandled exception of type ‘System.IO.FileNotFoundException’ occurred in GalaSoft.MvvmLight.WPF4.dll

            Additional information: Could not load file or assembly ‘Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

            Googling this indicated that the assembly is part of Team Explorer for VS2012.

            I had mistakenly assumed that by having VS2013 installed I would also have Team Explorer installed as well. So, in fairness to Martin, he is correct in stating above that you need to install it first.

            Therefore, you need to do the following.

            1) Download and install Team Explorer for VS2012 from the following link;

            https://www.microsoft.com/en-us/download/confirmation.aspx?id=30656

            2) Download and install Update 4 for Visual Studio 2012;

            https://www.microsoft.com/en-gb/download/details.aspx?id=39305

            3) Connect Team Explorer to your VSO instance – just because VS is configured/connected to VSO does not mean Team Explorer is as well.

            Re-run the app after doing this and you should now have your VSO Service Account credentials, as have I!

            Good luck!

          • I was not aware of a dependency on 2012… everything should be 2015… that would be a bug then.

          • Mayank Parashar

            I used vs 2015, and was able to connect. But the retrieve button does nothing.

          • I think you might need to use Team Explorer 2013. I need to update tge API to the new Nuget package but i have not yet.

  • opq

    Hi folks, I’ve been trying the new VS2015 Preview version at http://nakedalmweb.wpengine.com/tools/vso-service-credential-viewer/. It lets me connect (#1 shows “Connected to xyz”) but clicking Retrieve Credentials does nothing at all. Do you have any suggestions? Where can I get these credentials directly? Thanks.

    • Are you the owner of the account? You need to be the owner to be able to retrieve the service credentials…

  • Would you mind posting the source code for this?

    • ServiceIdentity defaultServiceIdentity = null;
      IAccessControlService acs = _SelectedTeamProjectCollection.GetService();
      defaultServiceIdentity = acs.ProvisionServiceIdentity();
      if (defaultServiceIdentity != null)
      {
      _ServiceUsername = defaultServiceIdentity.IdentityInfo.Name;
      _ServicePassword = defaultServiceIdentity.IdentityInfo.Password;
      }

  • Lane Goolsby

    Can you use this account with the REST API? I gave it a quick try and calls to the API kicks back (what appears to be) a login page. Also, is the account name the full string returned by the tool or just the bit in parenthesis (e.g. I get back ‘Account Service ({myhost})’, do we use the bit in {} or the whole string)?

    • I have not tried this account with the REST API, only with the Object Model.

  • What sort of security would add to give this account access to a build server like TeamCity?