Azure SQL serverless is not waking up on connection attempt


I'm testing Azure SQL Serverless and from SSMS it seems to work fine, but from my ASP.NET Core application it never wakes up.

Using SSMS I can open a connection to a sleeping Serverless SQL database and after a delay the connection will go through.

Using my ASP.NET Core application I tried the same. From the login page I tried to login, which opens a connection to the database. After 10 or 11 seconds (I looked up the default timeout and its supposed to be 15 seconds but in this case it always seems to be about 10.5 seconds +/-0.5s). According to the docs, the first connection attempt may fail but subsequent ones should succeed, but I can send multiple queries to the database and it always fails with the following error:

Microsoft.Data.SqlClient.SqlException (0x80131904): Database 'myDb' on server 
'' is not currently available.  Please retry the connection later.  If the 
problem persists, contact customer support, and provide them the session tracing ID of 

If I wake the database up using SSMS then the login web page can connect to the database and succeeds.

I have added Connect Timeout=120; to the connection string.

The connection does happen during an HTTP request that is marked async on the Controller, thought I don't know if that makes any difference.

Am I doing something wrong or is there something additional I need to do to get the DB to wake?

[updte] as an extra test wrote the following test

void Main()
    SqlConnection con = new SqlConnection(";Database=mydb;User Id=abc;Password=xyz;Connect Timeout=120;");



    var cmd = con.CreateCommand();
    cmd.CommandText = "select getdate();";

and got the same error.

asked on Stack Overflow Dec 18, 2019 by Zack • edited Dec 18, 2019 by Zack

1 Answer


I figured it out and its the dumbest thing.

This Azure SQL Server instance was migrated from another subscription and the group that migrated it gave it a new name, but they did something that allowed the use of the old name also. I'm researching to figure out how that was done. I will update this answer when I find out what that was.

As it turns out, using the old name with an Serverless Database won't wake up the db. Don't know why. But if you change to use the new/real server name it works. you do have to add a retry to the connection as it may fail the first few times.


The new server allows logins using the old name by using a Azure SQL Database Alias

answered on Stack Overflow Dec 18, 2019 by Zack • edited Dec 18, 2019 by Zack

User contributions licensed under CC BY-SA 3.0