Reputation: 65
I am building a Function App in Azure and I'm trying to connect to a third party SQL Server. I added in the Application Settings of the function the connection string like this:
Server=[servername],1433;Initial Catalog=[dbname];Persist Security Info=False;
User ID=[myuser];Password=[mypassword];MultipleActiveResultSets=False;
Encrypt=False;TrustServerCertificate=True;Connection Timeout=30;
Of course I replaced the strings on [] with the real values, but every time I try to connect to the server I get this error:
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 - The wait operation timed out.)
System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
When I try to connect to the same server, with the same credentials from my local Management Studio it connects correctly, so what am I doing wrong in the connection from Azure?
Thanks for the inputs!
Upvotes: 1
Views: 12510
Reputation: 2624
Your connection string looks correct. The error would indicate a connectivity issue. If it's working from your local SSMS, I must ask the obvious - is it a SQL database on-premise or a SQL Azure database in Azure? If it's on-premise you won't be able to connect to it from Azure unless you set up a hybrid connection or express route. If it's in Azure, you may have the server name wrong. A SQL Azure database would have a host name that is affixed with *.database.windows.net.
Upvotes: 1