I have an Asp.Net MVC webapp and I get the following error when I try to create a new Azure SQL user for the DefaultConnection.
[SqlException (0x80131904): Login failed for user 'myNewSQLuser'.]
On SQL Server Object Explorer I connected to the master database using the Server Admin login and I created a login for the new user with:
CREATE LOGIN myNewSQLuser WITH PASSWORD = 'myNewPwd';
Then with the same Sever Admin login I connected to the database corresponding to the webapp and created the user:
CREATE USER myNewSQLuser FROM LOGIN myNewSQLuser;
and then:
ALTER ROLE db_owner ADD MEMBER myNewSQLuser;
Then, on the web publish profile I have the following connection string:
Data Source=tcp:mydbserver.database.windows.net,1433;Initial Catalog=myAzureSqlDB;Persist Security Info=False;User ID=myNewSQLuser;Password=myNewPwd;Connect Timeout=30;Encrypt=True;TrustServerCertificate=False
When on Visual Studio, Edit Publish Profile, I am able to successfully test the connection string.
When I publish the MVC webapp to Azure App Service I see the "Login Failed" error mentioned above. However I am able to use the credentials for myNewSQLuser to connect to the database for example from Azure DataStudio.
User contributions licensed under CC BY-SA 3.0