Skip to main content

long_term_retention_policies

Creates, updates, deletes, gets or lists a long_term_retention_policies resource.

Overview

Namelong_term_retention_policies
TypeResource
Idazure.sql.long_term_retention_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
monthlyRetentionstringThe monthly retention policy for an LTR backup in an ISO 8601 format.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
timeBasedImmutabilitystringThe setting for whether to enable time-based immutability for future backups. When set, future backups will have TimeBasedImmutability enabled. Known values are: "Enabled" and "Disabled". (Enabled, Disabled)
timeBasedImmutabilityModestringThe setting for time-based immutability mode for future backup (Value can be either Locked or UnLocked. Only effective if TimeBasedImmutability is enabled). Caution: Immutability of LTR backup cannot be removed if TimeBasedImmutabilityMode is Locked. Known values are: "Locked" and "Unlocked". (Locked, Unlocked)
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
weekOfYearintegerThe week of year to take the yearly backup in an ISO 8601 format.
weeklyRetentionstringThe weekly retention policy for an LTR backup in an ISO 8601 format.
yearlyRetentionstringThe yearly retention policy for an LTR backup in an ISO 8601 format.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, server_name, database_name, policy_name, subscription_idGets a database's long term retention policy.
list_by_databaseselectresource_group_name, server_name, database_name, subscription_idGets a database's long term retention policy.
create_or_updateinsertresource_group_name, server_name, database_name, policy_name, subscription_idSet or update a database's long term retention policy.
create_or_updatereplaceresource_group_name, server_name, database_name, policy_name, subscription_idSet or update a database's long term retention policy.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringThe name of the database. Required.
policy_namestringThe policy name. Should always be Default. "default" Required.
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
server_namestringThe name of the server. Required.
subscription_idstring

SELECT examples

Gets a database's long term retention policy.

SELECT
id,
name,
monthlyRetention,
systemData,
timeBasedImmutability,
timeBasedImmutabilityMode,
type,
weekOfYear,
weeklyRetention,
yearlyRetention
FROM azure.sql.long_term_retention_policies
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND server_name = '{{ server_name }}' -- required
AND database_name = '{{ database_name }}' -- required
AND policy_name = '{{ policy_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

INSERT examples

Set or update a database's long term retention policy.

INSERT INTO azure.sql.long_term_retention_policies (
properties,
resource_group_name,
server_name,
database_name,
policy_name,
subscription_id
)
SELECT
'{{ properties }}',
'{{ resource_group_name }}',
'{{ server_name }}',
'{{ database_name }}',
'{{ policy_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
properties,
systemData,
type
;

REPLACE examples

Set or update a database's long term retention policy.

REPLACE azure.sql.long_term_retention_policies
SET
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND server_name = '{{ server_name }}' --required
AND database_name = '{{ database_name }}' --required
AND policy_name = '{{ policy_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
properties,
systemData,
type;