JobTemplate

A JobTemplate provides reusable settings for Jobs that need to be run repeatedly.

This topic gives an overview of the JobTemplate entity and also demonstrates how to execute various operations with the Media Services REST API.

Important

When accessing entities in Media Services, you must set specific header fields and values in your HTTP requests.
For more information, see Setup for Media Services REST API Development and Connecting to Media Services with the Media Services REST API.

JobTemplate Entity Properties

Property Type Description
Id

Read-only. Set by Media Services at creation time.
Edm.String Unique identifier.
Name

Optional.
Edm.String Friendly name for the job template.
Created

Read-only. Set by Media Services at creation time.
Edm.DateTime Represents the number of milliseconds since midnight Jan 1, 1970.
LastModified

Read-only. Set by Media Services.
Edm.DateTime This value is updated by Media Services after any property changes are made. It represents the number of milliseconds since midnight Jan 1, 1970.
JobTemplateBody

Required.
Edm.String An Xml document that defines what TaskTemplates and the number of input and output assets to use. For example,

<?xml version="1.0" encoding="utf-8"?> <jobTemplate> <taskBody taskTemplateId=”nb:ttid:UUID:0749DF78-5167-413D-91AA-31564ED1EF34”> … </taskBody> <taskBody taskTemplateId=”nb:ttid:UUID:0432DF78-5167-4132-942A-88241ED1AC34”> … </taskBody> </jobtemplate>

The format for the TaskBody content is the same as the Task’s TaskBody property plus the TaskTemplateId (or taskTemplateId) attribute. Each TaskTemplateId should be unique and correspond to the TaskTemplate in the TaskTemplates collection. The number of TaskBody elements has to be the same as the count of the TaskTemplates collection.
NumberofInputAssets

Optional. Cannot be updated after the entity has been created.
Edm.Int32 The number of input assets that can be used with this JobTemplate.
TemplateType

Required. Cannot be updated after the entity has been created.
Edm.Int32 The type of JobTemplate that can be created. Valid values are:

- SystemLevel = 0

- AccountLevel = 1

Note: SystemLevel JobTemplate types are reserved for Media Services. You must set this value to AccountLevel (that is "1").
TaskTemplates

Required.
TaskTemplates entity set Navigation property that references all associated TaskTemplate entities.

Create a JobTemplate

JobTemplates can be created with a POST HTTP request.

Method Request URI HTTP Version
POST https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates HTTP/1.1

Sample Request

To get the latest x-ms-version:, see Media Services REST.

POST https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates HTTP/1.1  
Content-Type: application/json;odata=verbose  
Accept: application/json;odata=verbose  
DataServiceVersion: 3.0  
MaxDataServiceVersion: 3.0  
x-ms-version: 2.19  
Authorization: Bearer <token value>  
Host: media.windows.net  
Content-Length: 608  
Expect: 100-continue  
  
{"Name" : "NewJobTemplate14ad96d1-2d14-4618-9014-08db7d227062", "TemplateType" : "1",  "JobTemplateBody" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><jobTemplate><taskBody taskTemplateId=\"nb:ttid:UUID:071370A3-E63E-4E81-A099-AD66BCAC3789\"><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody></jobTemplate>", "TaskTemplates" : [{"Id" : "nb:ttid:UUID:071370A3-E63E-4E81-A099-AD66BCAC3789", "Configuration" : "H.264 iPad", "MediaProcessorId" : "nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5", "Name" : "SampleTaskTemplate2", "NumberofInputAssets" : 1, "NumberofOutputAssets" : 1}] }  
  

List JobTemplates

JobTemplates can be retrieved using a GET HTTP request.

Method Request URI HTTP Version
GET https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates HTTP/1.1
Method Request URI HTTP Version
GET https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates('nb:jtid:UUID:ed10f137-7a8e-8343-9110-f54603d1136f') HTTP/1.1

Sample Request

To get the latest x-ms-version:, see Media Services REST.

GET https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates('nb:jtid:UUID:ed10f137-7a8e-8343-9110-f54603d1136f') HTTP/1.1  
Content-Type: application/json;odata=verbose  
Accept: application/json;odata=verbose  
DataServiceVersion: 3.0  
MaxDataServiceVersion: 3.0  
x-ms-version: 2.19  
Authorization: Bearer <token value>  
Host: media.windows.net  
  

Delete a JobTemplate

JobTemplates can be deleted using a DELETE HTTP request.

Method Request URI HTTP Version
DELETE https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates('jobtemplateid') HTTP/1.1

Sample Request

To get the latest x-ms-version:, see Media Services REST.

DELETE https://<accountname>.restv2.<location>.media.azure.net/api/JobTemplates('nb:jtid:UUID:1149a161-92c6-be40-8e9c-7bf640c05df6') HTTP/1.1  
Content-Type: application/json;odata=verbose  
Accept: application/json;odata=verbose  
DataServiceVersion: 3.0  
MaxDataServiceVersion: 3.0  
x-ms-version: 2.19  
Authorization: Bearer <token value>  
Host: media.windows.net  
Content-Length: 0  
  

See Also

ContentKey
Asset
AccessPolicy
AssetFile
Job
Locator
MediaProcessor
Task
TaskTemplate
Quotas and Limitations