Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Connect Azure Web App to Azure SQL Database

Azure has changed a fair bit from a year ago when I played with it.

I have a web app, and a Sql DB in my Azure resource group. I want my web app to read from my DB. I made a firewall rule so that my app can read from the DB at my workstation (running locally), and that is fine. But I want my app to read from the DB when it is deployed.

Do I just make a sql firewall rule to allow the app's IP address when hosted through to the DB? Or is there a way I can tell azure that the web app, and the DB in the same resource group,and it is a secure connection? Perhaps that they could communicate with each other on an internal connection?

I think in the old Azure you could 'link' an app and a DB and it accomplished this. But not sure what the procedure is in the updated Azure.

like image 310
sheamus Avatar asked Oct 14 '15 19:10

sheamus


People also ask

How can we connect Azure Web app to an Azure SQL Database?

Choosing the "Allow access to Azure services" option will allow the app service to connect to the MySQL server. On the MySQL server blade, under the Settings heading, click Connection Security to open the Connection Security blade for Azure Database for MySQL. Select ON in Allow access to Azure services, then Save.

Can Powerapps connect to Azure SQL?

App access to SQL Database serverYou can configure Power Apps access to Azure SQL Database server using the Azure portal, or stored procedure sp_set_firewall_rule. To configure access using the Azure portal, sign in to the Azure portal, and go to your SQL Server.


1 Answers

Go to your Azure SQL Database and get a copy of the connection string. (It won't have your password, so you'll have to add that in a minute.

Next, go to your Web App, click on the "All Settings" and under then click "Application Settings".

Scroll down to "Connection Strings" and either create a new connection string (and paste it in from the first step) or update the existing connection string. Be sure to update the password in your connection string.

If you create a new connection string, make sure it's the same name as that one you are referencing in your code or you will have to change your code and redeploy as that as well.

like image 80
Brian Sherwin Avatar answered Sep 18 '22 17:09

Brian Sherwin