Registration of an ITeamFoundationJobExtension is no longer possible - by JHofmann

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 836550 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 3/19/2014 12:15:50 AM
Access Restriction Public


The registration of an implementation of ITeamFoundationJobExtension worked perfectly fine in RTM but does no longer work in Update 2 RC. The following Code:

static void RegisterJob()
	Uri uri = new Uri("http://tfs:8080/tfs");
	TfsConfigurationServer tfs = TfsConfigurationServerFactory.GetConfigurationServer(uri);
	ITeamFoundationJobService jobService = tfs.GetService<ITeamFoundationJobService>();

	Guid jobGuid = new Guid("6506KC81-32F7-44AA-A036-2D8F675B349D");
	string jobName = "My TFS Job";
	string extensionName = "My.Tfs.Job";

	TeamFoundationJobDefinition definition = new TeamFoundationJobDefinition(jobGuid, jobName, extensionName, null, TeamFoundationJobEnabledState.Enabled);
	definition.Schedule.Add(new TeamFoundationJobSchedule(DateTime.Now.AddMinutes(5), 300));

Result in an exception:

Unbehandelte Ausnahme: Microsoft.TeamFoundation.Framework.Client.TeamFoundationServiceException: TF400444: The creation and deletion of jobs is no longer supported. You may only update the EnabledState or Schedule of a job.  
Failed to create, delete or update job id 6506ec81-31f7-44aa-a026-2d8f67ab349d. 
---> System.Web.Services.Protocols.SoapException: TF400444: 
The creation and deletion of jobs is no longer supported. You may only update the EnabledState or Schedule of a job.  
Failed to create, delete or update job id 6506ec81-31f7-44aa-a026-2d8f67ab349d.

Why is it no longer supported? How do I register my job now?
Sign in to post a comment.
Posted by Mohammed.Omar on 6/8/2014 at 2:39 AM
I`m facing the same issue with my TFS Extension, is there is any chance we can get an example of how we can use the server object model to create a custom TFS job with schedule ?
Posted by Chandru [MSFT] on 3/21/2014 at 9:36 AM
Looks like there is some sort of problem with our tool where attachments are not getting uploaded. Here is the code:

using Microsoft.TeamFoundation.Framework.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
    class Program
        static void Main(string[] args)
            if (args.Length != 2 && args.Length != 3)
                Console.WriteLine("Usage: ConsoleApplication7 <connection string> <plugin path> [collectionid]");

            String connectionString = args[0];
            String pluginDirectory = args[1];
            Guid collectionId = Guid.Empty;
            if (args.Length == 3)
                collectionId = Guid.Parse(args[2]);

            TeamFoundationServiceHostProperties deploymentHostProperties = new TeamFoundationServiceHostProperties();
            deploymentHostProperties.HostType = TeamFoundationHostType.Deployment | TeamFoundationHostType.Application;
            deploymentHostProperties.Id = Guid.Empty;
            deploymentHostProperties.PlugInDirectory = args[1];
            deploymentHostProperties.PhysicalDirectory = String.Empty;
            deploymentHostProperties.VirtualDirectory = string.Empty;

            DeploymentServiceHost host = null;

            // if after Dev12 Spring update.
            ISqlConnectionInfo connInfo = SqlConnectionInfoFactory.Create(connectionString, null, null);
            host = new DeploymentServiceHost(deploymentHostProperties, connInfo, true);

            // else if before spring update
            // deploymentHostProperties.ConnectionString = args[0];
            // host = new DeploymentServiceHost(deploymentHostProperties, true);

            // this creates a request against the deployment
            using (TeamFoundationRequestContext requestContext = host.CreateSystemContext())
                TeamFoundationJobService jobService = requestContext.GetService<TeamFoundationJobService>();

            if (collectionId != Guid.Empty)
                // for a collection request context
                using (TeamFoundationRequestContext requestContext = host.CreateSystemContext())
                    TeamFoundationHostManagementService hms = requestContext.GetService<TeamFoundationHostManagementService>();
                    using (TeamFoundationRequestContext collectionContext = hms.BeginRequest(requestContext, collectionId, RequestContextType.SystemContext))
                        TeamFoundationJobService jobService = collectionContext.GetService<TeamFoundationJobService>();
Posted by Chandru [MSFT] on 3/21/2014 at 9:33 AM
Sorry here it is.
Posted by JHofmann on 3/21/2014 at 8:59 AM
Hello Chandru,

I think you forgott the attachment?

Posted by Chandru [MSFT] on 3/21/2014 at 8:42 AM
Hi Jens,

Attached is a sample console app to spin up a request context. You need to add a reference to Microsot.TeamFoundation.Framework.Server and Microsoft.VisualStudio.Services.WebApi. You need to copy it to:

C:\Program Files\Microsoft Team Foundation Server 14.0\Tools

And then you can execute it using:

ConsoleApplication7 <connection string> <plugins>

Posted by JHofmann on 3/20/2014 at 11:38 PM
Hello Chandru,

I know the server model very well, but lets discuss the problem on a concrete scenario.

1. Develop a ITeamFoundationJobExtension
2. Deploy the Assembly into the Pluginsfolder of the JobAgent on the server
3. The job should be registered with a schedule of "every 5 minutes"
4. Run the registration once on the server

1. User your Visual Studio ;)
2. Not a problem
3+4. To use the server object model I need an instance of the TeamFoundationRequestContext. This can be achieved in 3 ways:
    2.1 Create an own application and instanciate an TeamFoundationRequestContext (wasn't really possible before Update 2 and is still not easy)
    2.2 Run logic within the request of a TSWA call (ITeamFoundationRequestFilter, ISubscriber and so on) but this is a dirty workaround because it forces me to do a dummy request
    2.3 Run logic inside an ITeamFoundationJobExtension ;) Which would be a chicken-and-egg problem :-D
Do I miss a fact? What's your suggested registration approach to register a scheduled job?
Code would be nice :)

Best Regards!
Posted by Chandru [MSFT] on 3/20/2014 at 7:27 PM

We ended up locking down those APIs to improve the security of TFS - to prevent a client would be able to add jobs to the server. Can you elaborate on what jobs you are adding using the client OM? The workaround is to use the server object model, specifically the TeamFoundationJobService ( class. This requires server access and can only be run by truly server administrators.

Posted by Macy [MSFT] on 3/19/2014 at 1:38 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information. If you require immediate assistance with this issue, please contact product support at
Posted by Macy [MSFT] on 3/19/2014 at 12:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If you require immediate assistance with this issue, please contact product support at