SQL Azure : Connection to SQL Azure throws exception - sql

When I connect to SQL Azure from my code, I get the following error.. I am able to connect to SQL Azure from SQL Server Management Studio successfully.
System.Data.SqlClient.SqlException: 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 requested name is valid, but no data of the requested type was found.)
I also tried connecting using sqlCMD and that connects without any issue. Only issue arises is during runtime when I get this exception.

You might also want to check to make sure your firewall allows outbound connections on port 1433.

There can be numerous reasons for this failure, I am listing out the scenarios and the options that needs to be allowed on the server.
If you are connecting an Azure SQL Instance using Sql server management studio while inside you company's network/firewall, first of all you will need to check if your company's firewall rules allow that or not.
On the AZURE SQL Server, make sure your IP address is in the allowed list.

I believe you just need to tick the checkbox "Allow other Windows Azure services to access this server" in Firewall Rules on your SQL Azure account (this will allow connecting to the db server from your deployed Azure application). Hope this helps.

It would be helpful if you post your connection string here. Also a sample app on connecting to sql azure using ado.net: http://msdn.microsoft.com/en-us/library/windowsazure/ee336243.aspx
Makesure you pay attention to the SqlConnectionStringBuilder properties.

If you have your IP added into firewall rules and allowing SQL
connection to Azure Services Enabled. It should work fine!

Related

Connecting SQL Server To Cognos Free Trial Version

I had subscribed for free trial for IBM Cognos. In that I have to connect my SQL server with it. I had tried all alternatives but none is working. According to the error, I had even given access of firewall through my system with port defined, also in sql server configuration manager. But still facing the same error when Testing the connection through ibm cognos.By default, we can only connect through jdbc.
Error
Connection In cognos
SQL Server configuration manager
Port Setting Inbound Firewall
The MSSQL database you are connecting to would not be local to the on demand server, so a host of localhost is likely not correct.
If the MSSQL is not publicly accessible you will need to use a secure gateway connection. https://www.ibm.com/docs/kk/cognos-analytics/11.1.0?topic=demand-secure-gateway-only
Additionally, public or private you will also need to add the following to the JDBC connection URL TrustServerCertificate=true

unable to connect to azure sql server from vsts

I am trying to deploy test.dacpac file using vsts to azure sql server, Given connection details properly and it is getting connected if I try to connect it from visual studio.
But when it tries to deploy file using vsts, gets error message -
A network-related or instance-specific error occurred while
establishing a connection to SQL Server azure
Not sure why this is happening.
Note: There is no firewall rule applied, it has default settings, though the virtual machine on which VSTS agent is installed is in another Azure AD subscription.
Do I have to look into VPN for this?
Please use the FQDN for database name instead of the IP address. e.g. myAzureSQLDB.windows.database.net.
You need to configure Azure SQL Database firewall. Make sure "Allow access to Azure Services" is turned on. If that does not work, then try adding firewall rule 0.0.0.0 to 255.255.255.255.

Unable to connect to Azure database from SQL Management Studio

When i am trying to connect to the Azure DB from SQL Management studio an getting teh below error. Not sure why am getting this error as i was able to acess the DB erlier from SQL Management Studio.
Need help on this.
TITLE: Connect to Server
Cannot connect to ijk3ffy48i.database.windows.net.
ADDITIONAL INFORMATION:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
BUTTONS:
OK
I think probably you haven't configure any Azure DB firewall rules to allow your computer's IP to communicate with your Azure DBs.
Simple things to check (not sure what you've tried so humour me here):
You're connected to the outside network.
Instance\Database name, username and password are correct.
Instance and database are online and connectable (Azure servers not down for scheduled maintenance or run out of paid services.)
Firewall rules are incorrect.
Also I think this question here is identical to your question. Try checking that out.

Working with SQL Azure from Starbucks

I have a SQL Azure database. For some reason, I can work with it when I'm at home, but not when I'm at Starbucks. I can successfully login to it and "manage" it via the web-based tool provided from the Windows Azure Portal. However:
When my web app tries to hit the database, I receive an error that says:
The provider did not return a ProviderManifestToken string.
When I try to hit the database from SQL Management Studio, I receive the following error:
Cannot connect to tcp:[serverName],[number].
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.)
(Microsoft SQL Server, Error: 10060)
I know my IP Address is unblocked, because as mentioned, I can use the web-based tool. I know the database is setup properly, because I can use it from home. However, when I seem to try to work from any local coffee shop, I'm stuck.
Thanks
the Web based Azure Portal doesn't use your local IP address to connect to your databases, it uses the ip address of the server hosting the portal.
since you're getting a new IP from coffee shops, either you add that in the Azure SQL Firewall or you open up your Azure SQL to all IPs.
if that doesn't work, then maybe your local coffee shop has firewall setting blocking port 1433...

Unable to connect to SQL Azure remotely from SSMS 2012

I am unable to connect to my SQL Azure database instance remotely using SQL Management Studio 2012. Firewall exception is in there for my local IP. I can connect successfully and admin the database using the browser based management link in my Azure account.
I just can't seem to connect to the database via SSMS or anything else like VS2012.
Here is the format I'm for my connection in SSMS:
Server Name: myservername.database.windows.net
Authentication: SQL Server Authentication
Login: myusername#myservername
Password: my-password
Connect to: (i've tried) "master", mydatabasename, <default>
Encryption: TRUE
Once again, I DO have the firewall rule active for my local IP address on the server instance of my Azure account.
When I attempt to connect, I receive this error:
A connection was successfully established with the server, but then an
error occurred during the pre-login handshake. (provider: SSL
Provider, error: 0 - the wait operation timed out.) (Microsoft SQL
Server, Error: 258)
When searching for that 258 error, I do not get many results related to SQL Azure. I appreciate any help.
Error 258 is generated due to some of the configuration within your machine if a secure network could be established between two endpoints and if one machine initiate secure channel. This problem could be very much machine specific and not SQL specific that why you did not find any resources on this regard.
Can you try using SQLCMD as described in the following troubleshooting guide and see if that works to isolate SSMS specific issues on the same machine:
http://social.technet.microsoft.com/wiki/contents/articles/1719.windows-azure-sql-database-connectivity-troubleshooting-guide.aspx
IF you capture and analyze network packets traffic you might be able to determine the root cause of connectivity error.