问题
I am using .NET backend for my Mobile App of Azure. I have been using Code-First migrations for my database and done many migrations and publishes so far. Everything was nice and smooth. Then I decided to reset my SQL Server password from Azure portal. After that things started to go south.
The problems that I faced after password change:
1- When I tried Add-Migration blabla in Package Manager Console, Visual Studio told me that all my previous migrations must be applied first.
2- I tried Update-Database. This time I got the Login failed for user 'xxxxxx' error.
After this error, I set my password the same as the old one from Azure portal.
This has allowed me to make migrations from console again. But after migration, when I trıed to Publish my code, I got the following screen again.
To fix this, I did the following:
1- Checked my ConnectionString and it is correct. Here is the ConnectionString of my database shown in Azure
And here is my ConnectionString which is located in Web.Config file.
<connectionStrings>
<add name="MS_TableConnectionString" connectionString="Server=tcp:xxxxxx.database.windows.net,1433;Initial Catalog=xxxxxxDatabase;Persist Security Info=False;User ID=xxx@xxxxxx; Password=xxxxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" />
</connectionStrings>
2- I have tried set Persist Security Info=True and TrustServerCertificate=True.
3- I reseted my Mobile App publish profile from Azure Portal.
None of these have worked for me. I am still getting the same error screen. What can I do?
EDIT1:
NOTE: When I start debugging locally from visual studio, I get the correct "Your mobile app is up and running" page without a problem.
Also at publish settings, "Validate Connection" and "Test Connection" returns positive results.
Extra info:
I have not used migrations for last two weeks, if this is important somehow.
I am able to view contents of my database from SSMS.
(Sorry if the question is too long and format is a little bit off. I haven't asked many questions)
回答1:
As usual, it is a very simple mistake that consumed so much time. Turns out Visual Studio part and my ConnectionStrings were correct. However, for some reason Mobile App in Azure Portal has been updated only for the first password change. You must check the ConnectionString in application settings.
Conclusion, if you manage to validate connections from Visual Studio while publishing, always check Azure Portal settings if you get this error.
来源:https://stackoverflow.com/questions/43982240/azure-publish-login-failed-for-user-xxxxxx