Skip to main content

Retrieving task history

This section provides information on how to retrieve a task history entry. 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.

API reference:

Required scopes:

  • Taskurai.Task.Read

Prerequisites

Retrieving a task

To retrieve a previously created task, use its ID.

var taskId = "dacf44c0-832e-4876-877a-31bb6f536835";
long runCount = 3;

var taskHistory = taskurai.GetTaskHistory(taskId, runCount);

Console.WriteLine(JsonSerializer.Serialize(taskHistory, serializerOptions));

Next, run the console application to validate:

dotnet run

The expected output should be:

{
"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"
}
}