An application hosted in Azure is raising this exception when trying to open connection with Sql Database:
An exception has been raised that is likely due to transient failure. If you are connecting to Sql Azure database, consider using SqlAzureStrategy.
I tried to turn firewall off, but it didn't work.
I'm able to connet to sql database tthrough sql management studio, but the web app isn't.
It uses EF6 to connect with database. Here is the peace of code, which raise error:
var usuario = Db.Usuario.Where(x => x.Login == login).FirstOrDefault();
if (usuario != null && usuario.ProfissionalID.HasValue)
{
usuario.Profissional = Db.Profissional.Where(x => x.ProfissionalID == usuario.ProfissionalID).FirstOrDefault();
}
return usuario;
I saw in Microsoft Article, a recomendation to use SqlAzureStrategy to try reconnect when first connection attempt fails:
public class DbContextConfiguration : DbConfiguration
{
public DbContextConfiguration()
{
SetExecutionStrategy("System.Data.SqlClient",
() => new SqlAzureExecutionStrategy(1, TimeSpan.FromSeconds(30)));
}
}
But it doesn't seem to be the solution of my problem, because when I implemented this, I got this error message:
Maximum number of retries (1) exceeded while executing database operations with 'SqlAzureExecutionStrategy'.