0
I am receiving the error message below when trying to connect to a database hosted in AZURE through a WEB application:
An Exception has been raiset that is likely due to Transient Failure. If you are Connecting to Sql Azure database, consider using Sqlazurestrategy.
I disabled the firewall of the bank to check if this could be the problem, but it did not solve.
I am able to connect through SQL Server Management Studio, but not through the application.
Application connects to bank via EF6
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 an article from Microsoft to implement this snippet of code to solve the problem:
public class DbContextConfiguration : DbConfiguration
{
public DbContextConfiguration()
{
SetExecutionStrategy(
"System.Data.SqlClient",
() => new SqlAzureExecutionStrategy(1, TimeSpan.FromSeconds(30)));
}
}
I did, but it seems to me that he makes several attempts of connection to each, until one is successful.
But it seems to me that the server is unstable, because I just could not connect, using Sqlazureexecutionstrategy.
I just got another error message:
Maximum number of retries (1) exceeded while executing database Operations with 'Sqlazureexecutionstrategy'.
Are you using C#? Post your connection code
– Sorack
Are you using
SqlAzureStrategy
?– Jéf Bueno
I think the problem is not the connection but something that you are trying to execute and there is giving the error above. the sql of Azure is very boring even.
– Dorathoto
put the connection string, removing the database name, user and password.
– Dorathoto
<add name="Entities" connectionString="Metadata=res:///Context.ControleHorasContext.csdl|res:///Context.ControleHorasContext.ssdl|res://*/Context.ControleHorasContext.msl;Provider=System.Data.Sqlclient;Provider Connection string="data source=XXX;initial Catalog=XXX;persist security info=True user id=XXX;password=XXX;Multipleactiveresultsets=True;App=Entityframework""providerName="System.Data.Entityclient" />
– Otavio Camargo