Stop Azure SQL Database
Published Aug 09 2023 04:40 PM 18.6K Views
Microsoft

We have several cases where our customers are looking for ways to stop an Azure SQL Database.

 

Some common scenarios where our customers request this option are when they want to decommission an Azure SQL Database and want to ensure that no one is using the database, or because the customer wants to save some money and stop the database during the hours they are not using it.

 

Stopping an Azure SQL Database is not currently supported, but there are several options that could be helpful in these scenarios:

 

  • Serverless Compute tier: Change the database to Azure SQL Database serverless  compute tier. Serverless is a compute tier for single databases in Azure SQL Database that automatically pauses databases during inactive periods when only storage is billed and automatically resumes databases when activity returns. 

If auto-pausing is enabled, but a database does not auto-pause after the delay period, the application or user sessions may be preventing auto-pausing. To see if there are any application or user sessions currently connected to the database, connect to the database using any client tool and execute the following query:

 

SELECT session_id,
       host_name,
       program_name,
       client_interface_name,
       login_name,
       status,
       login_time,
       last_request_start_time,
       last_request_end_time
FROM sys.dm_exec_sessions AS s
INNER JOIN sys.dm_resource_governor_workload_groups AS wg
ON s.group_id = wg.group_id
WHERE s.session_id <> @@SPID
      AND
      (
      (
      wg.name like 'UserPrimaryGroup.DB%'
      AND
      TRY_CAST(RIGHT(wg.name, LEN(wg.name) - LEN('UserPrimaryGroup.DB') - 2) AS int) = DB_ID()
      )
      OR
      wg.name = 'DACGroup'
      );

 

 

  • Change the Azure SQL Database service tier : If you will not use the database, but you still do not want to delete it, you can change your database service tier to Basic or Standard, reducing your database cost

 

  • Restore Azure SQL Database:  Depending on your database service tier and the retention policy, after deleting the database, you can restore it from the Azure SQL Server --> Deleted databases option. For further information, please check this link on how you can restore your deleted database: : Deleted database restore

 

  • Export the database to bacpac file: Before deleting an Azure SQL Database, you can also export the database to the BACPAC file and, if necessary, import it again. To export a database to a BACPAC file, follow these steps: Export a database to a BACPAC file

 

Co-Authors
Version history
Last update:
‎Aug 03 2023 06:02 AM
Updated by: