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.