0
votes

I started coding an ASP.NET webapp (with Visual Studio 2015). I'm having problems with the connection to my Azure SQL database. I can connect to the database via MSSM Studio. When I publish my app on the Azure webservice the app works fine. When I run my code locally I keep getting the following error:

SqlException: Cannot open server 'database' requested by the login. Client with IP address 'XX.XX.XX.XX' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.

Altough the firewall of the database service is set (I've even tried with range 0.0.0.0 too 255.255.255.255). On my computer port 1433 is allowed.

Any help is deeply appreciated.

1
Are you saying that you can connect to Azure SQL DB using SSMS, but cannot access it from the app which is running on the same host?Alexey Andrushkevich
Yes, that was what I meant. Meanwhile I found the error. The connectionstring was the problem. When I did connect with username "my_username@my_app.database.windows.net", I could only connect from a published Azure. When I did with username "[email protected]", Azure and localhost where working.ArneDEPR

1 Answers

0
votes

The problem was solved by editing the username of the database connectionstring.

my_username@my_app.database.windows.net -> only worked published on Azure (not via localhost)

[email protected] -> works published on Azure and with my localhost