SQL Azure connection failure

0

I'm getting the following error message when attempting to connect to the AZURE hosted bank 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 bank's firewall to see if this could be the problem, but it did not resolve.

I am able to connect through SQL Server Management Studio, but not through the application.

The application connects to a bank through 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 in a Microsoft article to implement this code snippet to solve the problem:

public class DbContextConfiguration : DbConfiguration
    {
        public DbContextConfiguration()
        {
            SetExecutionStrategy(
                "System.Data.SqlClient",
                () => new SqlAzureExecutionStrategy(1, TimeSpan.FromSeconds(30)));
        }
    }

I did this, but it seems to me that he makes several connection attempts to each, until one is successful.

But it seems to me that the server is unstable, since I could not get a connection, using SqlAzureExecutionStrategy.

Now I've received another error message:

Maximum number of retries (1) exceeded while executing database operations with 'SqlAzureExecutionStrategy'.

    
asked by anonymous 04.11.2016 / 14:14

1 answer

0

I do not think it's a database problem, otherwise you'd see a very different error from this one, something like saying that the IP address is not allowed by the firewall.

Instead I would try to look at this response from Markus Wagner where he says about the parameters of maxRetryCount and maxDelay . I think this should be a good start to make sure your code is well prepared to work with these classes.

Next, there are a number of best practices published on working with Azure SQL service. I would try to make sure you are meeting all of these best practices and trying to adjust where possible. I would try:

  • Minimize network latency
  • Reduce network usage by implementing application cache
  • Manage the network connection by keeping it open as little as possible
  • Tuning your SQL queries
  • Implement multi-tasking logic.

Translated from the answer in English

    
29.11.2016 / 09:41