Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect from Azure function app to my SQL Server?

So when some event goes to event hub it triggers Azure Function App, which should now connect to my SQL Server on virtual machine Windows Server 2012 and do some command there.

My VM is online and has password, my SQL Server instance has no password.

How do I create right connection string for connecting to this instance and be able to execute commands?

Note 1

All resources are on the same Azure Subscription

Note 2

I have IP address of virtual machine, I made login user so I have username and password to login on SQL Server instance, I tried using this format of connection string(https://www.connectionstrings.com/sql-server/):

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

Still can't connect

like image 892
Vess Avatar asked Dec 03 '25 16:12

Vess


1 Answers

  1. You must allow the connection through the firewall on the VM
  2. You must allow the traffic in the Network Security Group applied to your VM's network card
  3. You must use SQL authentication

Another option is that you use VNET integration in the Function App, though I am unaware how it works in Functions. Then you could use the private IP address, and by default only the VM firewall could block you.

Your connection string looks correct, the only thing that it is missing is the SQL Server instance name, but it will work if you are using the default name.

like image 95
juunas Avatar answered Dec 06 '25 07:12

juunas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!