Assuming that both virtual machine has a public network (which they have if you connect to them directly from your local machine) then the simplest option is to use the connection string to remote server. It is not important if the VM is on azure or not for that step.
Obviously you will need to open the network firewall port according to the port that your database server use
You did not provided any information about which database you use, so we cannot provide the exact implementation of the request