问题
I have a site hosted in Azure. It's a vanilla MVC project but when I try to register a user I'm getting an error as follows.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'BeepBeep'.
I'm not sure why it's giving me the error. The connection string in the config files looks like this (change credentials, of course).
<add name="DefaultConnection"
connectionString="
Server=tcp:f8goq0bvq7.database.windows.net,1433;
Database=MyDataBase;
User ID=BeepBeep@f8goq0bvq7;
Password=Bzzzz;
Encrypt=True;
TrustServerCertificate=False;
Connection Timeout=30;"
providerName="System.Data.SqlClient"/>
I've verified the same credentials with SQL Management Studio and I get logged in. Possibly, the authorization doesn't ask for DB credentials (although the error occurs while trying to register a new user via the default vanilla MVC site). Not sure where to poke it, though.
Any ideas on how to trouble-shoot it?
Edit
Based on the comments, we've verified that the database is set up to accept calls from Azure Services and that the hole in the firewall spans from 0.0.0.0 to 255.255.255.255. We also made sure that the credentials were correctly specified in the Azure portal (same result using them as well as the upload config file).
回答1:
In Azure
Did you change your database to be able to be Contacted from Azure Services?
You can find this on the configure tab of the DB Server.
回答2:
Where did you get the connection string?
Can you check if it has {} around your password?
<add name="DefaultConnection" connectionString="Server=tcp:myserver.database.windows.net;Database=aspnet-WebApplication1-20140927090028;User ID=myid;Password={mypsw};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
If yes, remove the {} from around your password...
Or
Can you check the Azure portal under Connection string section and see you have the correct password there
Or in the new Azure portal it looks like this:
- Select your website
- Click Application Settings
- Go to Connection Strings section and edit the password
Here is firewall setting in new portal for the SQL Server setting:
来源:https://stackoverflow.com/questions/32980039/unable-to-authorize-despite-connection-string-copied-from-azure