Configuring batch retention
The default retention time for tasks in Azure Batch is 7 days unless the compute node is removed or lost. We can, however, set the required retention time while adding a job.
Here is an example using REST APIs. The retentionTime
needs to be set in the request body as shown:
POST account.region.batch.azure.com/jobs/jobId/tasks?api-version=2021-06-01.14.0
Examine the following request body:
{ "id": "jobId", "priority": 100, "jobManagerTask": { "id": "taskId", "commandLine": "test.exe", "constraints": { "retentionTime": "PT1H" } }
PT1H
specifies 1 hour and uses the ISO_8601 format. You can learn more about the format here: https://en.wikipedia.org/wiki/ISO_8601#Durations.