You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/durable-task-scheduler/durable-task-scheduler-auto-purge.md
+94-26Lines changed: 94 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,70 +5,138 @@ ms.topic: conceptual
5
5
ms.date: 04/17/2025
6
6
---
7
7
8
-
# Set autopurge retention policies for Azure Functions Durable Task Scheduler (preview)
8
+
# Set autopurge retention policies for Azure Functions durable task scheduler (preview)
9
9
10
-
Large volumes of completed orchestration instance data can lead to storage bloat, incur higher storage cost, and increase performance issues. The autopurge feature for Durable Task Scheduler offers a lightweight, configurable, and adoptable way to manage orchestration instance clean-up without manual intervention.
10
+
Orchestration history data should be purged periodically to free up storage resources. Otherwise, the app will likely observe performance degradation as history data accumulates overtime. The Durable Task Scheduler offers a lightweight, configurable autopurge feature that helps you manage orchestration data clean-up without manual intervention.
11
11
12
-
Autopurge runs asynchronously in the backgroundto avoid using too many system resources and to prevent blocking or delaying other Durable Task operations. While autopurge doesn't run on a precise schedule, the clean-up rate roughly matches your orchestration scheduling rate.
12
+
Autopurge runs asynchronously in the background. It's optimized to avoid using too many system resources to prevent blocking or delaying other Durable Task operations. While autopurge doesn't run on a precise schedule, the clean-up rate roughly matches your orchestration scheduling rate.
13
13
14
14
## Enable autopurge
15
15
16
-
Enable autopurge by defining retention policies that control how long to keep completed, failed, or canceled orchestrations. Once enabled, autopurge deletes orchestration instances older than the retention period you set.
16
+
Autopurge is an opt-in feature. Enable it by defining retention policies that control how long to keep the data of orchestrations in certain statuses. The autopurge feature covers **completed, failed, canceled, or terminated** statuses only. It does not purge data associated of other statuses such as pending or running. Once enabled, autopurge will periodically delete orchestration instances older than the retention period you set.
17
17
18
-
You can configure autopurge using:
18
+
At the moment, retention policies you define will be applied to **ALL** task hubs in a scheduler.
19
19
20
-
- Azure Resource Manager
21
-
- Azure CLI
22
-
- Azure portal
20
+
You can define retention policies using:
23
21
24
-
# [Azure Resource Manager](#tab/arm)
22
+
- Azure Resource Manager (ARM)
23
+
- Azure CLI
24
+
- Azure portal
25
25
26
-
When configuring in Azure Resource Manager, you can set either a *specific* or a *default*retention policy. Retention value can range from 0 (purge immediately after completion) to any large number.
26
+
When configuring autopurge retention policy, you can set either a *specific* or a *default* policy. Retention value can range from 0 (purge immediately after completion) to the maximum integer value, with the unit being **days**. While there is no limit imposed on the max retention period, it's recommended that you don't keep large volumes of stale orchestration data for too long to ensure efficient use of storage resources and maintain app performance.
27
27
28
-
-**Specific policies**are applied only to the`orchestrationState` specified.
28
+
-**Default policy**purges orchestration data *regardless* of`orchestrationState`. The following policy purges orchestration data of all statuses covered by the feature after 2 days:
29
29
30
30
```json
31
31
{
32
-
"retentionPeriodInDays": 1,
33
-
"orchestrationState": "Completed"
32
+
"retentionPeriodInDays": 2
34
33
}
35
34
```
36
35
37
-
In this example, the retention policy tells Durable Task Scheduler to keep completed orchestrations for one day, and purge the rest.
38
-
39
-
- **Default policies** are applied to all purgeable statuses by omitting `orchestrationState`:
36
+
- **Specific policy** specifies purging of orchestration data for specific `orchestrationState`. The following policy tells Durable Task Scheduler to keep *completed* orchestration data for 1 day, after which this data is purged.
40
37
41
38
```json
42
39
{
43
-
"retentionPeriodInDays": 2
40
+
"retentionPeriodInDays": 1,
41
+
"orchestrationState": "Completed"
44
42
}
45
43
```
44
+
45
+
You can add specific policies to override the default policy that's applied to orchestrations of all statuses. In the example below, the second and third policies override the default policy, so data associated with completed orchestrations is deleted immediately and those associated with failed orchestrations is purged after 60 days. However, because there's no specific policy for orchestrations of statuses canceled and terminated, the default policy still applies so these data are purged after 1 day:
46
+
47
+
```json
48
+
[
49
+
{
50
+
"retentionPeriodInDays": 1
51
+
},
52
+
{
53
+
"retentionPeriodInDays": 0,
54
+
"orchestrationState": "Completed"
55
+
},
56
+
{
57
+
"retentionPeriodInDays": 60,
58
+
"orchestrationState": "Failed"
59
+
}
60
+
]
61
+
```
46
62
47
63
[For more information, see the API reference spec for Durable Task Scheduler retention policies.](/rest/api/durabletask/retention-policies/create-or-replace?view=rest-durabletask-2025-04-01-preview&preserve-view=true)
48
64
65
+
# [Azure Resource Manager](#tab/arm)
66
+
49
67
# [Azure CLI](#tab/cli)
50
-
Need
68
+
Create or update the retention policy by running the following:
69
+
70
+
```azurecli
71
+
az rest --method put --url "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME/retentionPolicies/default?api-version=2025-04-01-preview" --body '{
0 commit comments