$pol = Get-AzDataProtectionPolicyTemplate
$lifecycle = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Weeks -SourceRetentionDurationCount 5
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -LifeCycles $lifecycle -IsDefault $falseDatasourceType ObjectType
-------------- ----------
{Microsoft.Compute/disks} BackupPolicy
The first command gets the default policy template. The second command creates a weekly lifecycle object. The third command adds a weekly retention rule to the default policy.
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Weekly -RemoveRuleDatasourceType ObjectType
-------------- ----------
{Microsoft.Compute/disks} BackupPolicy
This command removes weekly retention rule if it exists in given backup policy.
$pol = Get-AzDataProtectionPolicyTemplate -DatasourceType AzureBlob
$opLifecycle = New-AzDataProtectionRetentionLifeCycleClientObject -SourceDataStore OperationalStore -SourceRetentionDurationType Days -SourceRetentionDurationCount 30
Edit-AzDataProtectionPolicyRetentionRuleClientObject -Policy $pol -Name Default_OperationalStore -LifeCycles $opLifecycle -IsDefault $trueDatasourceType ObjectType
-------------- ----------
{Microsoft.Storage/storageAccounts/blobServices} BackupPolicy
For AzureBlob, OperationalStore retention rules must be named Default_OperationalStore. The rule is added additively — the existing Default (VaultStore) retention rule on the policy template is preserved. Passing -Name Default with an OperationalStore lifecycle is rejected by validation.
Note: -OverwriteLifeCycle is deprecated and will be removed in an upcoming release. Setting -OverwriteLifeCycle $false blocks updating an existing retention rule; when $true or omitted, the existing rule's lifecycles are replaced in place — the default behavior once this parameter is removed.