3

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 Answer 1

3

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

2
  • Sorry. I should have commented that I have already set the IP to my machine's IP.
    – Cliff C
    Commented Oct 6, 2019 at 11:12
  • However, I just noticed the "Allow Azure services and resources to access this server". that was the problem.
    – Cliff C
    Commented Oct 6, 2019 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.