Task
A Task is an individual operation of work on an Asset and is defined in a Job.
This topic gives an overview of the Task
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.
Task Entity Properties
Property | Type | Description |
---|---|---|
Id Read-only. Set by Media Services at creation time. |
Edm.String | Unique identifier. |
Configuration Optional. |
Edm.String | Preset that defines processing actions, such as encoding, protection, and so on, that the Task will perform. Maximum length is 100000. |
EndTime Read-only. Set by Media Services. |
Edm.DateTime | The datetime when the task completed, failed, or was canceled. |
ErrorDetails Read-only. Set by Media Services. |
Collection(ErrorDetail) | A collection of codes and detailed messages describing any errors that occur when a Task is running. |
HistoricalEvents Read-only. Set by Media Services. |
Collection(TaskHistoricalEvent) | A collection of TaskHistoricalEvent objects that describe events associated with task execution. |
MediaProcessorId Required. |
Edm.String | Id of the MediaProcessor that will be used in the Task. Valid values can be retrieved by performing GET request on /API/MediaProcessors. |
Name Optional. |
Edm.String | Optional. Friendly name for the Task. Maximum length is 4000. |
PerfMessage Read-only. Set by Media Services. |
Edm.String | Contains performance information about the Task. |
Priority Optional. |
Edm.Int32 | The priority of the task. A higher value indicates a higher priority relative to other tasks. . For example, a task with Priority = 40 will be processed before a task with Priority = 30. The upper bound is equal to MaxInt. |
Progress Read-only. Set by Media Services. |
Edm.Double | Value indicating zero to 100 percent. |
RunningDuration Read-only. Set by Media Services. |
Edm.Double | The elapsed time (in seconds) for the Task. |
StartTime Read-only. Set by Media Services. |
Edm.DateTime | The datetime when the Task started. |
State Read-only. Set by Media Services. |
Edm.Int32 | The state of the Task. Valid values are: - None = 0 - Active = 1 - Running = 2 - Completed = 3 |
TaskBody Required. |
Edm.String | XML document that contains information about which input and output assets the Task should run against. A Task must have at least 1 input asset and 1 output asset. The XML document is of the following format. <taskBody> <inputAsset> JobInputAsset(0)</inputAsset> <inputAsset> JobInputAsset(1)</inputAsset> <outputAsset assetCreationOptions=”1” assetName=”output” storageAccountName=”mystoreagename”> JobOutputAsset(0) </outputAsset> <taskBody> The <outputAsset> element can have the following attributes: - assetCreationOptions (or AssetCreationOptions). This attributes can have one of the following values: None=0x0, StorageEncrypted=0x1, CommonEncryptionProtected=0x2, EnvelopeEncryptionProtected=0x4. The default is StorageEncrypted. - assetName (or AssetName). If none specified, Media Services sets a name in the following format: the parent outputAsset element suffixed by the Job Name (or the Job Id, if the Job Name is empty. - storageAccountName (or StorageAccountName). The name of the storage account where the output asset will reside. If not specified, the user’s default storage account is used. A task can depend on multiple tasks and also can have multiple dependents. For example, if Task A has an <outputAsset> that is referenced as an <inputAsset> by Task B, then Task B is dependent on Task A. As a result, Media Services has to finish processing Task A before it can process Task B. |
Options Required. Read-only after creation. |
Edm.Int32 | An enumeration value that describes the encryption options that a Task can be created with. Valid values are: - None = 0 - ProtectedConfiguration = 1 |
EncryptionKeyId Optional. |
Edm.String | The encrypted Key Id. |
EncryptionScheme Optional. |
Edm.String | The EncryptionScheme used with the configuration file. The valid value is "ConfigurationEncryption". |
EncryptionVersion Optional. |
Edm.String | The version of configuration encryption to use. The currently supported version is "1.0". |
InitializationVector Optional. |
Edm.String | The InitializationVector of the configuration file. Maximum length is 4000. |
OutputMediaAssets Read-only. Set by Media Services. |
Asset entity set | Navigation property that can be accessed by referencing a specific task by Id value. The returned entity set contains all of the OutputMediaAsset entities that are linked to the specified task. |
InputMediaAssets Read-only. Set by Media Services. |
Asset entity set | Navigation property that can be accessed by referencing a specific Task by Id value. The returned entity set contains all of the InputMediaAsset entities that are linked to the specified Task. |
TaskNotificationSubscriptions Required. |
TaskNotificationSubscription entity set | Defines the notification endpoint task state changes. Also, indicates whether to include task progress for which to be notified. |
Create a Task
Tasks are created by creating a Job. For an example, see How to encode an asset using Media Encoder Standard.
List Tasks
Tasks are retrieved using a GET HTTP request.
Method | Request URI | HTTP Version |
---|---|---|
GET | https://<accountname>.restv2.<location>.media.azure.net/api/Tasks | HTTP/1.1 |
Method | Request URI | HTTP Version |
---|---|---|
GET | https://<accountname>.restv2.<location>.media.azure.net/api/Jobs('jobid')/Tasks | 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/Jobs('nb:jid:UUID:b1f956b3-774c-bb44-a3f7-ee47e23add31')/Tasks 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
See Also
AccessPolicy
Asset
ContentKey
Job
Job
JobTemplate
Locator
MediaProcessor
TaskTemplate
Quotas and Limitations