Skip to content

Commit 78ad2ac

Browse files
committed
reordered creation options; added info property arguments
1 parent d2445c0 commit 78ad2ac

File tree

1 file changed

+78
-69
lines changed

1 file changed

+78
-69
lines changed

articles/azure-functions/durable/durable-task-scheduler/durable-task-scheduler-auto-purge.md

Lines changed: 78 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ Autopurge operates asynchronously in the background, optimized to minimize syste
1313

1414
## How it works
1515

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 purges data associated only with the following statuses:
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 purges orchestration data associated only with the following statuses:
1717
- `Completed`
1818
- `Failed`
1919
- `Canceled`
2020
- `Terminated`
2121

22-
Autopurge ignores data associated with the following statuses:
22+
Autopurge ignores orchestration data associated with the following statuses:
2323
- `Pending`
2424
- `Running`
2525

26-
[Once enabled,](#enable-autopurge) autopurge periodically deletes orchestration instances older than the retention period you set.
26+
[Once enabled,](#enable-autopurge) autopurge periodically deletes orchestration data older than the retention period you set.
2727

2828
> [!NOTE]
2929
> Retention policies you define are applied to **all** task hubs in a scheduler.
@@ -55,11 +55,11 @@ When configuring an autopurge retention policy, you can set either a *specific*
5555
}
5656
```
5757

58-
Add specific policies to override the default policy applied to orchestrations, regardless of status. In the following example, the second and third policies override the default policy (`"retentionPeriodInDays": 1`).
59-
- Data associated with completed orchestrations is deleted as soon as possible (approximately every 5 minutes).
60-
- Data associated with failed orchestrations is purged after 60 days.
58+
Add specific policies to override the default policy applied to orchestrations. In the following example, the second and third policies override the default policy (`"retentionPeriodInDays": 1`).
59+
- Data associated with `completed` orchestrations is deleted as soon as possible (approximately every 5 minutes).
60+
- Data associated with `failed` orchestrations is purged after 60 days.
6161

62-
However, since no specific policy is set for canceled or terminated orchestrations, the default policy still applies to them, purging their data after 1 day.
62+
However, since no specific policy is set for `canceled` or `terminated` orchestrations, the default policy still applies to them, purging their data after 1 day.
6363

6464
```json
6565
[
@@ -83,35 +83,64 @@ However, since no specific policy is set for canceled or terminated orchestratio
8383

8484
You can define retention policies using:
8585

86-
- Bicep
86+
- Durable Task CLI
8787
- Azure Resource Manager (ARM)
88-
- Azure CLI
88+
- Bicep
8989

90-
# [Bicep](#tab/bicep)
90+
# [Durable Task CLI](#tab/cli)
9191

92-
You can create or update retention policies by adding the `retentionPolicies` configuration to your Bicep file. Make sure you're pulling from the latest preview version.
92+
First, run `az extension update --name durabletask` to update the extension if you have it installed, or `az extension add --name durabletask` to install if you don't currently have the extension.
9393

94-
```bicep
95-
resource exampleResource 'Microsoft.DurableTask/schedulers/retentionPolicies@2025-04-01-preview' = {
96-
parent: parentResource
97-
name: 'default'
98-
properties: {
99-
retentionPolicies: [
94+
Create or update the retention policy by running the following command.
95+
96+
```azurecli
97+
az durabletask retention-policy create --scheduler-name SCHEDULER_NAME --resource-group RESOURCE_GROUP --default-days 1 --completed-days 0 --failed-days 60
98+
```
99+
The following are properties for specifying the retention duration of orchestration data of different statuses:
100+
- `--canceled-days` or `-x` : The number of days to retain canceled orchestrations.
101+
- `--completed-days` or `-c` : The number of days to retain completed orchestrations.
102+
- `--default-days` or `-d` : The number of days to retain orchestrations.
103+
- `--failed-days` or `-f` : The number of days to retain failed orchestrations.
104+
- `--terminated-days` or `-t` : The number of days to retain terminated orchestrations.
105+
106+
**Example response**
107+
108+
If creation is successful, you receive the following response.
109+
110+
```json
111+
{
112+
"id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAMER/retentionPolicies/default",
113+
"name": "default",
114+
"properties": {
115+
"provisioningState": "Succeeded",
116+
"retentionPolicies": [
100117
{
101-
retentionPeriodInDays: 30
102-
}
118+
"retentionPeriodInDays": 1
119+
},
103120
{
104-
"retentionPeriodInDays": 0,
105-
"orchestrationState": "Completed"
106-
}
121+
"orchestrationState": "Completed",
122+
"retentionPeriodInDays": 0
123+
},
107124
{
108-
retentionPeriodInDays: 60
109-
orchestrationState: 'Failed'
125+
"orchestrationState": "Failed",
126+
"retentionPeriodInDays": 60
110127
}
111128
]
112-
}
129+
},
130+
"resourceGroup": "RESOURCE_GROUP",
131+
"systemData": {
132+
"createdAt": "2025-04-23T23:41:17.3165122Z",
133+
"createdBy": "[email protected]",
134+
"createdByType": "User",
135+
"lastModifiedAt": "2025-04-23T23:41:17.3165122Z",
136+
"lastModifiedBy": "[email protected]",
137+
"lastModifiedByType": "User"
138+
},
139+
"type": "microsoft.durabletask/schedulers/retentionpolicies"
113140
}
114141
```
142+
> [!TIP]
143+
> Add `--help` to learn more about a Durable Task CLI command. For example, learn about the arguments and properties of the retention policy create command by running `az durabletask retention-policy create --help`
115144
116145
# [Azure Resource Manager](#tab/arm)
117146

@@ -175,58 +204,42 @@ If creation is successful, you receive the following response.
175204
}
176205
```
177206

178-
# [Azure CLI](#tab/cli)
179-
180-
Create or update the retention policy by running the following command.
181-
182-
```azurecli
183-
az durabletask retention-policy create --scheduler-name SCHEDULER_NAME --resource-group RESOURCE_GROUP --default-days 1 --completed-days 0 --failed-days 60
184-
```
185-
186-
**Example response**
207+
# [Bicep](#tab/bicep)
187208

188-
If creation is successful, you receive the following response.
209+
You can create or update retention policies by adding the `retentionPolicies` configuration to your Bicep file. Make sure you're pulling from the latest preview version.
189210

190-
```json
191-
{
192-
"id": "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAMER/retentionPolicies/default",
193-
"name": "default",
194-
"properties": {
195-
"provisioningState": "Succeeded",
196-
"retentionPolicies": [
211+
```bicep
212+
resource exampleResource 'Microsoft.DurableTask/schedulers/retentionPolicies@2025-04-01-preview' = {
213+
parent: parentResource
214+
name: 'default'
215+
properties: {
216+
retentionPolicies: [
197217
{
198-
"retentionPeriodInDays": 1
199-
},
218+
retentionPeriodInDays: 30
219+
}
200220
{
201-
"orchestrationState": "Completed",
202-
"retentionPeriodInDays": 0
203-
},
221+
"retentionPeriodInDays": 0,
222+
"orchestrationState": "Completed"
223+
}
204224
{
205-
"orchestrationState": "Failed",
206-
"retentionPeriodInDays": 60
225+
retentionPeriodInDays: 60
226+
orchestrationState: 'Failed'
207227
}
208228
]
209-
},
210-
"resourceGroup": "RESOURCE_GROUP",
211-
"systemData": {
212-
"createdAt": "2025-04-23T23:41:17.3165122Z",
213-
"createdBy": "[email protected]",
214-
"createdByType": "User",
215-
"lastModifiedAt": "2025-04-23T23:41:17.3165122Z",
216-
"lastModifiedBy": "[email protected]",
217-
"lastModifiedByType": "User"
218-
},
219-
"type": "microsoft.durabletask/schedulers/retentionpolicies"
229+
}
220230
}
221231
```
222-
223232
---
224233

225234
## Disable autopurge
226235

227-
# [Bicep](#tab/bicep)
236+
# [Durable Task CLI](#tab/cli)
228237

229-
Remove `retentionPolicies` from your Bicep file.
238+
Delete the retention policies using the following command. The Durable Task Scheduler stops cleaning orchestration data within 5 to 10 minutes.
239+
240+
```azurecli
241+
az durabletask retention-poliby delete --scheduler-name SCHEDULER_NAME --resource-group RESOURCE_GROUP
242+
```
230243

231244
# [Azure Resource Manager](#tab/arm)
232245

@@ -236,13 +249,9 @@ Delete the retention policy using an API call.
236249
DELETE https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME/retentionPolicies/default?api-version=2025-04-01-preview
237250
```
238251

239-
# [Azure CLI](#tab/cli)
240-
241-
Delete the retention policies using the following command. The Durable Task Scheduler stops cleaning orchestration data within 5 to 10 minutes.
252+
# [Bicep](#tab/bicep)
242253

243-
```azurecli
244-
az durabletask retention-poliby delete --scheduler-name SCHEDULER_NAME --resource-group RESOURCE_GROUP
245-
```
254+
Remove `retentionPolicies` from your Bicep file.
246255

247256
---
248257

0 commit comments

Comments
 (0)