locked
Cannot find CreateJob method RRS feed

  • Question

  • Hello,

    In http://azure.microsoft.com/sv-se/documentation/articles/batch-dotnet-get-started/ :

    using (IWorkItemManager wm = client.OpenWorkItemManager())
    {
       ICloudJob job = wm.CreateJob(PoolName);
       job.WorkItemName = WorkItemName;
       job.Commit();
    }
    Console.WriteLine("Workitem successfully added.");
    Console.ReadLine();

    I cannot find this CreateJob method. Should I use the following instead ? How then ?

    ICloudWorkItem workItem = wm.CreateWorkItem(WorkItemName);
    workItem.Commit(); // 400 Bad Request

    Thanks

    Monday, November 3, 2014 11:36 AM

Answers

  • Hi Vianney,

    The above sample is referring to an API which we have removed from the client library.  It looks like our documentation was not updated correctly to reflect that.  I've made a note to update the documentation (you'll see it reflected in a day or two).

    In the meantime, the method you can use is below.

    using (IWorkItemManager workItemManager = batchClient.OpenWorkItemManager())
    {
        IToolbox toolbox = batchClient.OpenToolbox();
        ITaskSubmissionHelper taskSubmissionHelper = toolbox.CreateTaskSubmissionHelper(workItemManager, PoolName);
    
        taskSubmissionHelper.WorkItemName = workItemName;
    
        taskSubmissionHelper.Commit();
    }

    -Matt

    • Marked as answer by Vianney Tuesday, November 4, 2014 11:53 PM
    Monday, November 3, 2014 5:29 PM

All replies

  • Hi Vianney,

    The above sample is referring to an API which we have removed from the client library.  It looks like our documentation was not updated correctly to reflect that.  I've made a note to update the documentation (you'll see it reflected in a day or two).

    In the meantime, the method you can use is below.

    using (IWorkItemManager workItemManager = batchClient.OpenWorkItemManager())
    {
        IToolbox toolbox = batchClient.OpenToolbox();
        ITaskSubmissionHelper taskSubmissionHelper = toolbox.CreateTaskSubmissionHelper(workItemManager, PoolName);
    
        taskSubmissionHelper.WorkItemName = workItemName;
    
        taskSubmissionHelper.Commit();
    }

    -Matt

    • Marked as answer by Vianney Tuesday, November 4, 2014 11:53 PM
    Monday, November 3, 2014 5:29 PM
  • Alternatively: to create a WorkItem you can use IWorkItemManager.CreateWorkItem().

    The 400 bad request exception will contain more information (see Exception Explainer) but it is essentially telling you that one or more required properties are missing.

    For the WorkItem, you must set the JobExecutionEnvironment before .Commit().

    d




    • Edited by DarylMsft Monday, November 3, 2014 7:14 PM -word
    Monday, November 3, 2014 6:04 PM
  • In terms of background:

    There is a workflow feature that used to be started via "CreateJob".  It is now found via:

          batchCli.OpenToolbox().CreateTaskSubmissionHelper()

    This helper workflow simplifies the path to getting tasks running in that it will create the workitem (optionally pool too), wait for the job, stage files to blob-storage, create SASs, and add the tasks.  Some of the samples use this helper (ie: HelloWorld, etc.).

    The "CreateJob" name proved to be problematic so we moved the feature in the object model just prior to Public Preview.  The name/position might well change again before GA as we incorporate customer feedback and usage. It IS true that the helper creates a WorkItem... but it is an implicit feature.  CreateWorkItem() is more direct (but requires the caller to understand at least minimum workitem properties before Commit() can succeed.).

    Monday, November 3, 2014 6:37 PM
  • Thank you Matt, I needed confirmation about this.
    I am quite surprised the official tutorial is not up to date.
    BTW, I have sent a pull-request will all the errors I have found.
    I'm just waiting for the CLA validation.

    Vianney, having a lot of fun with Azure Batch!

    Tuesday, November 4, 2014 11:53 PM