How do I stop and start a SQL Azure database?

2020-05-27 04:39发布

I am running an Azure based site that for historic reasons uses two databases on two servers. I have copied the data from the static data-source so that both reside on the same server. I am fairly sure I have removed all references to the old server from the live code, and indeed the Azure dashboard shows no connections over the last month. But to be 100% sure before I delete the server I would like to stop it and test the live site. If anything goes wrong I would then like to start it again. In SQL Server Management Studio this is usually straightforward, I can right-click on a server in the SQL Server Management Studio object explorer and select 'Stop' and then if needed 'Start'. However 'Stop' and 'Start' are not listed in the options for SQL Azure servers, nor is there anything I can see in the management pages on the Azure portal.

So my question is simple - how do I stop and start a SQL Azure database?

6条回答
神经病院院长
2楼-- · 2020-05-27 05:16

as Praggie mentioned, you cannot stop/start the SQL Azure servers. A SQL Azure Database resides on a shared host. there are other tenants on that server. you have access to the database, but not to the corresponding hosting server.

you can rename the database and if there's any app connecting to it, then they'd fail.

查看更多
我想做一个坏孩纸
3楼-- · 2020-05-27 05:19

We had an issue with a Sql Azure db and were pretty sure it was in the server/service. We couldn't find the stop & start button, but did find a workaround:

Scale the database to another tier and then scale it back!

It solved our db issue.

Everybody says you don't need a stop/start button... but sometimes the theory differs from practice. Even Azure has issues :)

查看更多
贪生不怕死
4楼-- · 2020-05-27 05:30

You can simply block the IPs (remove all the firewall rules, so that no one can connect)

查看更多
5楼-- · 2020-05-27 05:31

Warning, the top google result for "restart sql server database azure" gives one of the options for restarting as running DBCC STACKDUMP('Manual Failover – Reason: something').

Running that definitely causes something to happen, but in our case after 5 minutes the DTUs still weren't registering and the portal wasn't able to pull information on the size of the database.

After waiting 10 minutes for it to come back we ended up changing the tier and roughly 18 minutes later the tier change finished and the database was accessible again.

查看更多
太酷不给撩
6楼-- · 2020-05-27 05:38

A quick and dirty rename can work pretty good. Admin rights required!

USE master;  
GO  
ALTER DATABASE MyDatabaseIsAvailable
Modify Name = MyDatabaseIsNoMoreAvailable;  
GO  

do the opposite once you're done. The good thing is you can 'stop' a single Database when you have more than one on the same server

查看更多
淡お忘
7楼-- · 2020-05-27 05:39

If this helps: in my situation, the database was locked. I could not alter tables, schema or anything else.

The way I found to handle this case was forcing read only and read write with rollback immediate.

 ALTER DATABASE [MyDB]
 SET READ_ONLY
 WITH ROLLBACK IMMEDIATE; 

 ALTER DATABASE [MyDB]
 SET READ_WRITE
 WITH ROLLBACK IMMEDIATE; 
查看更多
登录 后发表回答