Trouble connecting azure web app to azure sql database

Jonathan McCary 1 Reputation point
2020-08-04T20:19:26.327+00:00

I was able to connect to my azure SQL database from my local host using the connection string. My get call returns a 200 response with data. However, when I publish the web application to azure and change the base url to my web application site, I get a 401 unauthorized response for the same get call.

I have added the connection string to the web application configuration and clicked the button to "Allow Azure services and resources to access this server" but saw no change after saving and restarting the application. Still a 401 response.

Am I missing something in terms of adding another client IP in the SQL server firewall for the published web application?

Is there perhaps a specific format that my connection string should be in that I'm unaware of?

Thanks for any help.

Azure SQL Database
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,401 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jeremy Brooks 572 Reputation points Microsoft Employee
    2020-08-05T01:20:29.32+00:00

    If the HTTP status is a 401 you should first make sure any code path you have is not returning the 401. A 401 is an HTTP status code where as SQL would return an access denied message or another SQL specific message if there was an issue talking to the SQL server.