0
votes

I am having an issue with the Azure connectionstring, i kept on having the error : "Login failed for user 'myuser'." after adding the connectionstring to the configuration of the app service and trying to call the REST API

I tried to login via SSMS with the same credentials and it is working and if i use the same connection string in web.config it is working as well.

my theory is maybe because i have the "ampersand" in the password and it is not escape .. i also tried to connect to a different database instance within the same resource group which the pwd does not have the "&" and was able to connect

Does anyone seen this issue before and how to resolve it ?

Azure connectionString does not work :

metadata=res:///Model.EFData.csdl|res:///Model.EFData.ssdl|res://*/Model.EFData.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:xxx.database.windows.net,1433;initial catalog=xxx;user id=myuser;password=Mypassword&123;Persist Security Info=True;TrustServerCertificate=True;multipleactiveresultsets=True;application name=EntityFramework"

Web.config connectionString when deploy to azure (note the password is escape with amp;)

metadata=res://*/;provider=System.Data.SqlClient;provider connection string="data source=tcp:xxx.database.windows.net,1433;initial catalog=xxx;user id=myuser;password=Mypassword&123;Persist Security Info=True;TrustServerCertificate=True;multipleactiveresultsets=True;application name=EntityFramework"

1
Replace the ampersand with &, the HTML entity. web.config is parsed as XML so this should get converted to & when passed to Azure SQL. -- w3schools.com/html/html_entities.asp - evilSnobu

1 Answers

0
votes

So i found it i tried to create a new EDMX with the user name and pwd and copy the connection string to Azure and it is working.. It is just strange when i compare the 2 connections string the credentials are identical (to human eyes) but i guess the one generated has some different