Saturday, May 11, 2013

"No Such Host is Known..." - Windows Azure

Today, while working on a hobby project hosted on Windows Azure, I ran into one of those nagging problems that does not easily explain itself. My few updates to a project that had grown dusty, a web publish, presented me with the dreaded YSoD proclaiming "No Such Host Is Known."



This was a new error for me but the stack trace lead me to believe that it had to do with the database.

[Win32Exception (0x80004005): No such host is known]

[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 - No such host is known.)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555

Maybe it was Azure. Nope, everything was indeed running as it should be there. Maybe my connection string in the project. Still no, Web.config looked good. I'll try doing a EF "Update-Database" via the Package Manager Console. Sure enough this was working too.



So what was the cause of this problem?


Well it turns out my hunch about the Web.config connection string was pretty darn close. Azure provides a way to obfuscate your connection string details by overriding the connection string with details provided in the Azure site configuration settings.

Via the Azure Portal, go to your sites "Configure" tab and you can view the "Connection String" overrides.




It was their connection string override that was causing the problem.

Well, okay, it was mostly their fault.

My issue was that my connection string name in Azure did not match the one in my system. Making the connection string name equal to the one in my system, a quick save, and back in business.

My online searches did not have much to say on fixing this issue for a site hosted in Azure but hopefully this can help you with troubleshooting your issue. Good luck and happy coding.

No comments:

Post a Comment