Godaddy Website does not connect to my Azure Database

Andy Gonzalez 0 Reputation points
2023-05-22T20:02:14.6333333+00:00

I have my Azure database, but I host my website with Godaddy, but I cannot connect to the database from the website. I can connect to the database using MS Management Studio, but not from the website.

My firewall rules are from 0.0.0.0 to 255.255.255.255, in connectivity I selected version TLS 1.0, and the connection policy is set to Default.

I changed the web.config file by adding

<system.web>
  	<customErrors mode = "On"/>
	<trust level="Full" />
</system.web>

I get the following error:

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) ---> System.ComponentModel.Win32Exception (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e) at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen() --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsyncTState,TResult ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number:10060,State:0,Class:20 --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsyncTState,TResult at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at SolHispWeb.Controllers.WebContactsController.Create(ContactUsViewModel webContact) in C:\Users\solhi\source\repos\SolHispWeb\TestBootstrap\Controllers\WebContactsController.cs:line 43

Azure SQL Database
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,194 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,277 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Alberto Morillo 32,891 Reputation points MVP
    2023-05-22T20:40:37.1933333+00:00

    Make sure the connection string is similar to:

    DataProvider: sqlserver
    DataConnectionString: Data Source=tcp:myservername.database.windows.net,1433;Initial Catalog=databasename;Integrated Security=False;User ID=LoginForDb@myservername;Password=mypassword;Connect Timeout=30;Encrypt=True
    
    
    
    

    Make sure the Azure SQL service tier can handle the size of the database you currently have on GoDaddy. Here you will find storage limits of each service tier.

    Once the connection works, make sure to whitelist the IP address of your web site only on Azure SQL firewall. Make sure you add a retry logic to connections from your web site to Azure SQL.

    0 comments No comments

  2. Oury Ba-MSFT 16,471 Reputation points Microsoft Employee
    2023-05-22T23:13:46.1866667+00:00

    @Andy Gonzalez Thank you for reaching out.

    My understanding is that you are trying to connect to your Azure SQL database from your website Godaddy hosted in the Azure ut facing the above error message.

    In addition to @Alberto Morillo 's answer above. Please also consider upgrading the version of the TLS to a more recent one 1.2 for example since you mentioned that the version being used is TLS 1.0.

    Which service tier are you using?

    Please comment below if none of the solution provided don't work.

    Regards,

    Oury