Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access SQL Azure DB from Azure website but same connection string works from local website

I am unable to access SQL Azure DB from Azure website even though same connection string works from local website. The error is as follows:

System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'XYZ'.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,
Boolean breakConnection, Action`1 wrapCloseInAction) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, 
Boolean callerHasConnectionLock, Boolean asyncClose) <...>  
Error Number:18456,State:1,Class:14  <...>

After checking previous answers,

  1. I have made added my database to my website's linked resources on Azure portal. enter image description here
  2. I have added 0.0.0.0 - 255.255.255.255 range to my firewall exclusion list Not needed! enter image description here
  3. I have made sure that my connection string usage does not allow any ambiguity.
  4. I have made sure that ApplicationDbContext is built using correct connection string.

What else I could try?

The website code is here.

like image 407
Yulia V Avatar asked Nov 28 '25 15:11

Yulia V


1 Answers

I'm not sure which portal you're using, but... in the preview portal (portal.azure.com), your database settings page will have a link to the server, and there you'll find firewall settings. And aside from IP ranges, there's an option to allow Azure services to have access to your database. You'll need that enabled.

Same thing in manage.windowsazure.com - the settings are accessible through the Configure tab.

like image 106
David Makogon Avatar answered Nov 30 '25 04:11

David Makogon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!