Suspend and resume transparent data encryption scans on Azure SQL Database to protect performance.
Suspend and resume for transparent data encryption (TDE) scans in Azure SQL Database lets you temporarily halt an encryption scan during busy periods and continue it later from the exact point where it stopped, instead of starting over.
Why we built it
TDE protects your databases, backups, and transaction log files at rest, without any changes to your application. When you turn encryption on or off, the service runs an encryption scan across the database. The scan duration is proportional to the size of the database, and for large databases it can take a long time.
While it runs, the scan consumes CPU and I/O, which can affect user workloads during peak hours. Until now, scans were all or nothing: once started, a scan had to complete.
What is new
Suspend and resume gives database administrators and owners control over the encryption scan:
- Suspend temporarily halts the encryption scan on the data and log files and releases the resources it was using.
- Resume restarts the scan from the point of suspension.
While a scan is suspended, new or updated data pages continue to be handled according to the direction of the scan. If you were encrypting, new pages are still encrypted. If you were decrypting, new pages are written unencrypted.
You can also toggle direction while a scan is suspended. For example, you can start encryption, suspend it, and then turn encryption off. The decryption scan starts from the beginning. The same applies in reverse.
This works for TDE with service-managed keys and with customer-managed keys.
Manage encryption status in the Azure portal
You can see and control the state of the encryption scan directly in the Azure portal. On the transparent data encryption page of your database, the encryption status shows whether the database is encrypted, being encrypted, or suspended, and offers the matching action.
Encryption in progress
While the scan is running, the status shows that encryption is in progress and a suspend button appears to pause the scan.
Suspended
When you suspend the scan, the status changes to suspended and a resume button appears so you can continue from where you left off.
Encrypted
Once the scan completes, the database shows as encrypted.
Use T-SQL to suspend and resume
The same commands that exist in SQL Server are available in Azure SQL Database.
Suspend an encryption scan
ALTER DATABASE my_db_name SET ENCRYPTION SUSPEND
Resume a suspended encryption scan
ALTER DATABASE my_db_name SET ENCRYPTION RESUME
Start encryption, suspend it, then decrypt again
ALTER DATABASE my_db_name SET ENCRYPTION ON
ALTER DATABASE my_db_name SET ENCRYPTION SUSPEND
ALTER DATABASE my_db_name SET ENCRYPTION OFF
Monitor the scan
Track the state of the scan with the sys.dm_database_encryption_keys dynamic management view, which reports the encryption state of the database and its encryption keys.
SELECT DB_NAME(database_id), *
FROM sys.dm_database_encryption_keys
The percent_complete column shows the progress of the encryption state change.
Get started and share feedback
Suspend and resume is available in public preview for Azure SQL Database. Public preview features are covered by the Supplemental Terms of Use for Microsoft Azure Previews. To learn more about how TDE works, including service-managed and customer-managed keys, see the TDE overview on Microsoft Learn.
Try it on your databases and tell us what you think. Your feedback helps us shape the feature before general availability.