How to Submit a Job to OneCompute Platform
The OneCompute Platform Client has two methods for submitting a job:
Method | Return type | Description |
---|---|---|
SubmitJobAsync | IJobMonitor | Submits the specified Job and returns a job monitor that allows the client to monitor the status and progress of the job. |
SubmitJobAsync | string | Submits the specified job with the cancellation token as an asynchronous operation. Returns the job id. |
The following code example shows how to use the OneCompute Platform Client to submit a job to the OneCompute Platform.
var job = new Job
{
ServiceName = "CalcWorker", // Name of the OneCompute Application
Work = work
};
var monitor = await oneComputePlatformClient.SubmitJobAsync(job);
Notice that this example tags onto the code examples of the preceding section on how to create jobs.
First-time submission of a job in a service-to-service scenario
Note that if the type of authentication used is client credentials, then the first submission of a job will fail. This is because the service user represented by the client credentials ("id" and "secret") needs to be activated in the OneCompute Platform, and associated with a company account, just like an ordinary user would have to be.
After the service user has been activated, the job needs to be resubmitted.