# AzureContainerRegistryResource.WithPurgeTask

- Module: [Aspire.Hosting.Azure.ContainerRegistry](/reference/api/go/aspire.hosting.azure.containerregistry.md)
- Defined on: [AzureContainerRegistryResource](/reference/api/go/aspire.hosting.azure.containerregistry/azurecontainerregistryresource.md)
- Version: `17.0.0`
- Kind: `method`

Adds a scheduled ACR purge task to remove image tags and eligible untagged manifests.

## Remarks

Tag removal alone does not reclaim storage. The task also deletes eligible
previously untagged manifests and can break digest-based pulls and rollbacks.
Tags younger than `ago` are also retained, so more than `keep` tags can remain.
Eligible untagged manifests are deleted regardless of age. Locked artifacts and dependencies of retained images are protected.

## Definition

```go
type AzureContainerRegistryResource interface {
    // ... omitted for brevity
    WithPurgeTask(
        schedule string,
        options ...*WithPurgeTaskOptions,
    ) AzureContainerRegistryResource
}
```

## Signature

```go
WithPurgeTask(
    schedule string,
    options ...*WithPurgeTaskOptions,
) AzureContainerRegistryResource
```

## Parameters

- `schedule` (`string`) -- The cron schedule for the purge task timer trigger. Must be a five-part cron expression (`minute hour day-of-month month day-of-week`); seconds are not supported.
- `options` (`...*WithPurgeTaskOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithPurgeTaskOptions` argument.

- `Filter` (`*string`) -- An optional filter for the `acr purge --filter` parameter. Only repositories matching this filter will be purged. Defaults to `".*:.*"` (all repositories and tags) when `null`.
- `Ago` (`*float64`) -- The age threshold based on last modified time, in milliseconds. Older matching tags are eligible for removal unless protected by the keep limit. Defaults to zero.
- `Keep` (`*float64`) -- The minimum number of newest matching tags to retain per repository, regardless of age. Must be greater than zero. Defaults to 3.
- `TaskName` (`*string`) -- An optional name for the ACR task resource. If not provided, a name is auto-generated based on existing purge tasks to avoid conflicts. If a task with the specified name already exists, an `ArgumentException` is thrown.

## Returns

[`AzureContainerRegistryResource`](/reference/api/go/aspire.hosting.azure.containerregistry/azurecontainerregistryresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [AzureContainerRegistryResource](/reference/api/go/aspire.hosting.azure.containerregistry/azurecontainerregistryresource.md) -- `handle`
