Listing task history
This section provides information on how to list task history. The history of the task are the past runs (for example previous failed or timed-out runs of the task).
The latest (or current) run can also be returned by the task history calls.
API reference:
Required scopes:
Taskurai.Task.Read
Prerequisites
- You have completed the Setup sample application tutorial.
Listing task history
Use the following command to list task history:
- C#
var taskId = "dacf44c0-832e-4876-877a-31bb6f536835";
var taskHistoryList = await taskurai.ListTaskHistoryAsync(taskId);
Console.WriteLine(JsonSerializer.Serialize(taskHistoryList, serializerOptions));
Next, run the console application to validate:
dotnet run
The expected output should be:
[
{
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Created": "2024-06-03T12:44:18.5802995+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:44:24.553324+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:44:18.5802995+00:00",
"Stopped": "2024-06-03T12:44:24.553324+00:00",
"Status": "Failed",
"ProvisioningState": "Failed",
"StatusCode": 408,
"error": {
"code": "taskurai_error_task_timeout",
"message": "Task dacf44c0-832e-4876-877a-31bb6f536835 failed due to timeout (Visiblity timeout, Max Runs, Max Duration).",
"details": []
},
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 6,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
},
{
"Id": "fd545a8d-c81d-4682-a0d5-163d122370e8",
"Created": "2024-06-03T12:44:18.4990563+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:44:12.8801356+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:44:12.8801346+00:00",
"Status": "Running",
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 5,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
},
{
"Id": "a223db1b-b393-42fc-bfd2-070929ca0552",
"Created": "2024-06-03T12:44:12.7729994+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:44:07.1818492+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:44:07.1818483+00:00",
"Status": "Running",
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 4,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
},
{
"Id": "437e319f-679a-4b1c-866c-a12ab995bc30",
"Created": "2024-06-03T12:44:07.1102547+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:44:01.4855607+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:44:01.4855598+00:00",
"Status": "Running",
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 3,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
},
{
"Id": "556fba27-bf7e-4a88-b726-77c2dd5a4450",
"Created": "2024-06-03T12:44:01.3667011+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:43:55.779268+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:43:55.7792669+00:00",
"Status": "Running",
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 2,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
},
{
"Id": "fcc2471e-29bb-480e-b407-ff8ac6b05931",
"Created": "2024-06-03T12:43:55.7144937+00:00",
"Task": {
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Config": {
"Command": "testRetry1SecNoComplete",
"Arguments": [
{
"Name": "arg1",
"Value": "abc-123"
}
],
"Tags": {
"BusinessUnit": "unit-a",
"Kind": "Console app tags"
},
"Subject": "Samples",
"Description": "This is a test task",
"ExternalId": "my-id-123456",
"MaxDuration": 30,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"Id": "dacf44c0-832e-4876-877a-31bb6f536835",
"Data": {
"Name": "Test",
"Value": "Some value",
"Properties": [
"Some property",
"Another property"
]
}
},
"Created": "2024-06-03T12:43:44.4386342+00:00",
"Modified": "2024-06-03T12:43:50.1654637+00:00",
"Started": "2024-06-03T12:43:50.165424+00:00",
"RunStarted": "2024-06-03T12:43:50.1654634+00:00",
"Status": "Running",
"ProvisioningState": "Running",
"StatusCode": 202,
"Archived": false,
"Postponed": false,
"Cancelled": false,
"RunCount": 1,
"CorrelationId": "dacf44c0-832e-4876-877a-31bb6f536835",
"WorkerName": "WorkerTimeout",
"WorkerImage": "internaltest.azurecr.io/taskurai-worker-timeout:latest"
}
}
]
Customize list options
- C#
You can customize the list history options using the ListTaskHistoryOptions like this:
var taskId = "dacf44c0-832e-4876-877a-31bb6f536835";
var taskHistoryList = await taskurai.ListTaskHistoryAsync(taskId, new ListTaskHistoryOptions()
{
Offset = 10,
Limit = 10
});
Console.WriteLine(JsonSerializer.Serialize(taskHistoryList, serializerOptions));
Overview of the task history list options:
Property | Type | Default | Description |
---|---|---|---|
Offset | integer | 0 | Start at the position to enumerate tasks |
Limit | integer | 10 | Limit the number of items returned (maximum = 100) |