Create Job

 

The Create Job request creates a new job.

Request

The Create Job request is specified as follows. Replace <subscription-id> with your subscription ID, <cloud-service-id> with your cloud service ID, <job-collection-id> with the ID of the job collection, and <job-id> with the ID of the new job itself.

Method

Request URI

PUT

https://management.core.windows.net/<subscription-id>/cloudServices/<cloud-service-id>/resources/scheduler/~/jobCollections/<job-collection-id>/jobs/<job-id>?api-version=2014-04-01

If you do not want to include a job id, you can send a POST request and a job ID will be generated by the service instead.

URI Parameters

None.

Request Headers

The following table describes required and optional request headers.

Request Header

Description

x-ms-version

Required. Specifies the version of the operation to use for this request. This header should be set to 2013-06-01 or a later version.

Content-type

Required. The content type of the request body.

Request Body

The format of a request body for a Scheduler HTTP job is as follows:



{
    "startTime": "2013-01-30T12:08:00-08:00",
    "action":
    {
        "type": "http",
        "request":
        {
            "uri": "https://bing.com/",
            "method": "GET",
            "headers": 
            {
                "Content-Type": "text/plain"
            }
        }
    },
    "recurrence":
    {
        "frequency": "minute",
        "interval": 30,
        "count": 10
    },
    "state": "enabled"
}

The format of a request body for a Scheduler storage queue job is as follows:

{
  "action": {
    "type": "storageQueue",
    "queueMessage": {
      "storageAccount": "testStorage",
      "queueName": "testQueue",
      "sasToken": "s?sv=2012-02-12&si=SchedulerAccessPolicy2%2F26%2F2014%207%3A30%3A45%20PM&sig=Cg%2BYX4KK31JexMD5Rl%2B6C7oeBzMG4dz9f2to8jS",
      "message": ""
    }
  },
  "recurrence": {
    "frequency": "day",
    "interval": 2
  }
}

All elements of the request body and its JSON payload are described in the topic Scheduler Concepts, Terminology, and Entity Hierarchy. To learn how to create a SAS token, refer to Create and Use a Shared Access Signature.

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

A successful operation returns status code 201 (Created). When PUT overwrites the existing value for a job, a 200 (OK) is returned instead.

Response Headers

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Header

Description

x-ms-request-id

A value that uniquely identifies a request made against the Management service. For an asynchronous operation, you can call get operation status with the value of the header to determine whether the operation is complete, has failed, or is still in progress. See Tracking Asynchronous Service Management Requests for more information.

Response Body

The response is formatted as follows for a Scheduler HTTP job:

{
  "id": "job1",
  "startTime": "2013-01-30T20:08:00+00:00",
  "action": {
    "request": {
      "uri": "http:\/\/bing.com\/",
      "method": "GET",
      "headers": {
        "content-Type": "text\/plain"
      }
    },
    "type": "http"
  },
  "recurrence": {
    "frequency": "minute",
    "count": 10,
    "interval": 30
  },
  "state": "enabled"
}

The response is formatted as follows for a Scheduler storage queue job:

{
    "id": "testStorageJob",
    "action": {
        "queueMessage": {
            "storageAccount": "testStorage",
            "queueName": "testQueue",
            "sasToken": "s?sv=2012-02-12&si=SchedulerAccessPolicy2%2F26%2F2014%207%3A30%3A45%20PM&sig=Cg%2BYX4KK31JexMD5Rl%2B6C7oeBzMG4dz9f2to8jS",
            "message": ""
        },
        "type": "storageQueue"
    },
    "recurrence": {
        "frequency": "day",
        "interval": 2
    },
    "state": "enabled",
    "status": {
        "nextExecutionTime": "2014-04-16T18:29:50.412005Z",
        "executionCount": 0,
        "failureCount": 0,
        "faultedCount": 0
    }
}


Authorization

Any management certificate associated with the subscription specified by <Subscription-Id> can be used to authenticate this operation. For additional details, see Authenticating Service Management Requests

Outbound Authentication

To add authentication information and call an external service that requires authentication, please refer to the details in the topic Scheduler Outbound Authentication

Actions, Recurrence, and Retry Policy

To learn more how actions and error actions recur and are tried, please refer to Scheduler Concepts, Terminology, and Entity Hierarchy 

Sample Request and Response

The following sample URI makes a request for fictional subscription named mysub and fictional cloud service mycs:

PUT https://management.core.windows.net/mysub/cloudServices/mycs/resources/scheduler/~/jobCollections/myjc/jobs/job1?api-version=2014-04-01

The request is sent with the following headers:

x-ms-version: 2013-06-01
Host: management.core.windows.net
Content-Type: application/json

The request is sent with the following body for a Scheduler HTTP job:


{
  "startTime": "2013-01-30T12:08:00-08:00",
  "action": {
    "type": "http",
    "request": {
      "uri": "http:\/\/bing.com\/",
      "method": "GET",
      "headers": {
        "Content-Type": "text\/plain"
      }
    }
  },
  "recurrence": {
    "frequency": "minute",
    "interval": 30,
    "count": 10
  },
  "state": "enabled"
}

Similarly, the request is sent with the following body for a Scheduler storage queue job:


{
  "action": {
    "type": "storageQueue",
    "queueMessage": {
      "storageAccount": "testStorage",
      "queueName": "testQueue",
      "sasToken": "s?sv=2012-02-12&si=SchedulerAccessPolicy2%2F26%2F2014%207%3A30%3A45%20PM&sig=Cg%2BYX4KK31JexMD5Rl%2B6C7oeBzMG4dz9f2to8jS",
      "message": ""
    }
  },
  "recurrence": {
    "frequency": "day",
    "interval": 2
  }
}

After the request has been sent, the following response is returned for the Scheduler HTTP job:

HTTP/1.1 201 Created
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 252
Content-Type: application/json; charset=utf-8
Expires: -1
x-ms-servedbyregion: ussouth
x-ms-request-id: b033c32fecfa2374bcf134f4cfcff198
Date: Sat, 26 Oct 2013 23:42:18 GMT

{
  "id": "job1",
  "startTime": "2013-01-30T20:08:00+00:00",
  "action": {
    "request": {
      "uri": "http:\/\/bing.com\/",
      "method": "GET",
      "headers": {
        "content-Type": "text\/plain"
      }
    },
    "type": "http"
  },
  "recurrence": {
    "frequency": "minute",
    "count": 10,
    "interval": 30
  },
  "state": "enabled"
}


Similarly, the following response is returned for the Scheduler storage queue job:

HTTP/1.1 201 Created
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 470
Content-Type: application/json; charset=utf-8
Expires: -1
Server: 1.0.6198.64 (rd_rdfe_stable.140410-1446) Microsoft-HTTPAPI/2.0
x-ms-servedbyregion: ussouth2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
x-ms-request-id: 96b0ce532370889eae94dc77bf310bfa
Date: Wed, 16 Apr 2014 18:29:30 GMT

{
    "id": "testStorageJob",
    "action": {
        "queueMessage": {
            "storageAccount": "testStorage",
            "queueName": "testQueue",
            "sasToken": "s?sv=2012-02-12&si=SchedulerAccessPolicy2%2F26%2F2014%207%3A30%3A45%20PM&sig=Cg%2BYX4KK31JexMD5Rl%2B6C7oeBzMG4dz9f2to8jS",
            "message": ""
        },
        "type": "storageQueue"
    },
    "recurrence": {
        "frequency": "day",
        "interval": 2
    },
    "state": "enabled",
    "status": {
        "nextExecutionTime": "2014-04-16T18:29:50.412005Z",
        "executionCount": 0,
        "failureCount": 0,
        "faultedCount": 0
    }
}

See Also

What is Scheduler?
Get Started Using Scheduler in the Management Portal
Scheduler Concepts, Terminology, and Entity Hierarchy
How to Build Complex Schedules and Advanced Recurrence with Azure Scheduler
Scheduler PowerShell Cmdlets Reference
Scheduler High-Availability and Reliability
Scheduler Outbound Authentication
Scheduler Limits, Defaults, and Error Codes
Plans and Billing in Azure Scheduler
Azure Scheduler Pricing
Azure Scheduler Videos
Register Subscription
Get Resource Provider Properties
Create Cloud Service2
Get Cloud Service1
Get Cloud Services2
Delete Cloud Service2
Create Job (Scheduler API)
Update Job1
Get Job1
Delete Job2
Check Name Availability1
Create Job Collection
Update Job Collection
Get Job Collection
Delete Job Collection
Get All Jobs
Get Job History1