Rediger

Del via


Restore a deleted logical server in Azure SQL Database (preview)

Applies to: Azure SQL Database

This article explains how to configure soft delete retention for your logical server in Azure, and how to restore a logical server that's been deleted within the retention period.

After you enable soft delete retention, you can list and restore a deleted logical server to its original state during the retention window. You can configure a soft delete retention period for your logical server and restore a deleted server by using the Azure portal, PowerShell, or the Azure CLI.

Important

The ability to configure a soft delete retention period and restore a deleted logical server is currently in preview. Any logical server older than two years automatically has a soft delete retention period of seven days. Logical servers less than two years old have soft delete retention disabled by default.

Overview

Soft delete retention helps protect logical servers in Azure from accidental deletion by retaining deleted server metadata for a configurable period. When you enable soft delete retention and a logical server is deleted, Azure doesn't immediately remove the server permanently. Instead, Azure keeps the server in a soft-deleted state for the configured retention period. While the server is in this state, you can discover and restore it. The retention period is configured in days at the logical server level and determines how long a deleted server remains recoverable.

Soft delete retention is useful in the following scenarios:

  • Accidental deletion – Recover a logical server that was unintentionally deleted.
  • Operational safety – Reduce risk during automation, scripted cleanup, or bulk operations.
  • Development and testing – Safely delete and restore servers in test or non-production environments.
  • Governance and protection – Add a recovery buffer to mitigate irreversible loss due to human error.

When the logical server is deleted, the user databases are deleted. When you restore the server, you can also restore databases within retention.

Prerequisites

To configure soft delete retention, you need the following prerequisites:

Permissions

To configure soft delete retention, or restore a deleted server, the user needs to be a member of the SQL Server contributor role.

Configure soft delete retention

You can configure soft delete retention for a logical server when you create the server by using PowerShell or the Azure CLI. You can update the retention period for an existing server by using the Azure portal, PowerShell, or the Azure CLI.

Set the retention period from 0 to 7 days. Setting the retention to 0 days disables soft delete retention.

Currently, you can't configure the soft delete retention period when you create a new logical server in the Azure portal. You can only set the retention period for an existing server.

To view or configure soft delete retention for an existing server in the Azure portal, follow these steps:

  1. Go to your logical server in the Azure portal.

  2. Under Data Management, select Delete protection (preview) to open the Delete protection (preview) pane.

  3. On the Delete protection (preview) pane:

    • The Keep deleted servers (in days) field shows the current retention period for the server. If the value is Not enabled or 0, soft delete is OFF and the server can't be recovered if deleted. A value between 1 and 7 indicates the number of days a deleted server is retained and available for restore.
    • Modify the value in the Keep deleted servers (in days) field to set the desired retention period for the server. You can enter a value between 1 and 7 to specify the number of days to retain a deleted server.

    Screenshot of the Delete protection pane for a SQL server in the Azure portal.

  4. Select Apply to save your changes.

Delete a logical server

If you delete a logical server with soft delete retention enabled, the server enters a soft-deleted state for the configured retention period. You can delete a server by using the Azure portal, PowerShell, or the Azure CLI.

If soft delete retention isn't configured for the server, deleting the server results in permanent deletion with no retention or recovery option.

In the Azure portal, you can delete a logical server from the following locations:

  • Use the Delete button on the command bar of your logical server's Overview pane.
  • Select the checkbox next to the server you want to delete on the SQL logical servers pane of the Azure SQL Hub, and then use the Delete button on the command bar.

List soft-deleted servers

You can list soft-deleted logical servers to see which servers are available to restore within the retention period by using the Azure portal, PowerShell, or the Azure CLI.

To view a list of soft-deleted servers follow the steps in Restore a deleted server to open the Restore deleted server pane. The dropdown list of deleted servers shows all soft-deleted servers available to restore for a subscription within their specified retention period.

Restore a soft-deleted logical server

You can restore a soft-deleted logical server during the retention period by using the Azure portal, PowerShell, or the Azure CLI.

When the logical server is deleted, the user databases are deleted. When you restore the server, you can also restore databases within retention.

To restore a soft-deleted logical server in the Azure portal:

  1. Go to the Azure SQL hub in the Azure portal.

  2. Under Azure SQL Database, select SQL logical servers to open the SQL logical servers pane.

  3. On the SQL logical servers pane, select Restore from the command bar to open the Restore deleted server pane:

    1. Select the Subscription from the dropdown list.
    2. Select the Location of the deleted server from the dropdown list.
    3. Select a Deleted server from the dropdown list. The dropdown shows all soft-deleted servers available to restore within their specified retention period.

    Screenshot of the restore deleted server pane in the Azure portal.

  4. Select Restore to restore the deleted server. The restored server has the same name and configuration as the deleted server. It's restored to its original state at the time of deletion. After the restore operation completes, the server is available in the list of active servers in the Azure portal.

Permanently delete a logical server

If you want to permanently delete a logical server, make sure the soft delete retention period is set to 0 to disable retention before deleting the server. When the server is deleted, it's deleted permanently.

If your server has already been deleted with a specified retention but you want to permanently delete it before the retention period expires, follow these steps:

  1. Restore the server.
  2. Set the soft delete retention period to 0 to disable retention.
  3. Delete the server again.

Limitations

The following limitations apply when using soft delete retention for your logical server:

  • If you use the built-in Azure policy to enforce Microsoft Entra-only authentication, you can't restore the deleted server. To restore the server, remove the policy and then restore the server.
  • When the logical server is deleted, the managed identities are deleted.
  • When the logical server is restored, any encryption with Customer Managed Key (CMK) needs to be reconfigured.