3
votes

ASP.NET connection-string works when app run from VS 2019 but fails when published to Azure

SQL Server connection-string works to access an SQL Database hosted on Azure when I run from VS (2019) but when I publish the site to Azure and access the web site (from Azure) I get an access problem - using the same connection-string.

Error from Azure troubleshooter:- "Connection attempts to your database xxxxxxxxxxxxxx have recently failed due to invalid credentials. To resolve this issue, contact your service administrator for valid credentials. If this problem persists, share these troubleshooting steps with your service administrator."

I am the administrator and the credentials work in the following contexts:

  • app run from VS and accessing the Azure based SQL Server database
  • access the same database from Microsoft's SSMS

Any ideas?

Connection-string:- "Data Source=tcp:xxxxxxxxxx.database.windows.net,1433;Database=TradingPortal;User ID=xxxxxxxxxx; Password=xxxxxxxx;Trusted_Connection=False;Integrated Security=False; Encrypt=True; Connection Timeout=30; TrustServerCertificate=False;MultipleActiveResultSets=True;"

1

1 Answers

3
votes

You will have to allow certain IP addresses to connect to it. Look at the SQL Database server's Firewall setting. You can the IP address of your computer (or IP range), to access SQL Database

Make sure to enable Allow Azure services and resources to access the server

enter image description here