Azure connection crashes constantly

0

I am using Visual Studio 2015 , C# and database SQL Server Azure and developing a Windows Forms project.

Everything works perfectly, except that when I spend some time without running my application for testing, I get the error:

  

Network-specific or instance-specific error when connecting to SQL Server. The server was not found or was not accessible.       Verify that the instance name is correct and that SQL Server is configured to allow remote connections.       (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) --- >        System.ComponentModel.Win32Exception (0x80004005) : The network path was not found

The error appears on the line:

private void Form1_Load(object sender, EventArgs e)
{
    -> this.usuarioTableAdapter.Fill(this.estoqueDataSet.Usuario);
}

Then I need to open Server Explorer , click on my Data Connection and click on the refresh button there it will be normal again.

I am new to both Visual Studio and Azure and want to know if this is normal, if there is a risk of occurring when my client is using my program and if you have to "disable" this shutdown.

** Here is my firewall configuration: ** link

    
asked by anonymous 09.12.2016 / 22:17

1 answer

2

When using Azure Tools with Visual Studio, it will assist you in several small tasks to speed development.

Azure SQL, by default, does not accept connections from outside the Azure Data Centers, in order to have this access, if it is necessary to add the necessary IPs or range of IPs in the Azure SQL Firewall .

From the symptoms you mentioned, it seems to me that Azure Tools is adding its IP to this list automatically and transparently. I believe that by staying a while without testing the app, your IP can change and exit the list of IPs, causing exactly the error you are getting.

In the exception list, you can put a * , so the bank can receive a connection from anywhere. But I discourage doing it, totally.

The best solution I see for your scenario is to put a WebAPI interface between your Windows application and your Azure SQL database.

See this post on how to create your first service rest with WebAPI . It's very simple and will help a lot in the maintenance of your application.

And to communicate your Windows application with your WebAPI service, I recommend using Fluent HTTP . Very simple, intuitive and elegant.

Finally, I recommend too much, rather than your application with WinForms, to do it with UWP - Universal Windows Platform. Windows Forms is legacy technology and I strongly believe that it will come out completely in a few years.

    
13.12.2016 / 08:44