Azure – Connect Azure AppService web app to Azure Virtual Machine through private network. Possible

azure

I'm trying to figure out a way to connect my web app running in Azure AppServices to an Azure Virtual Machine that's hosting a database server.

I can see that the Azure VM has both a public and private IP. I'm trying to get the AppService instance to connect to the Azure VM through its private IP. I've googled and read through the docs but I can't seem to figure out if this is even possible to do.

So I guess my question is this, is it possible to somehow configure private IPs for AppService instances in order to pull this off?

PS: There's an additional use-case where I would need for two AppService instances to talk to each other through private IPs as well. Are either cases possible?

Best Answer

To allow your App Service to access your VM over it's private IP you need to enable Virtual Network (VNET) integration. This will allow your app to communicate directly with your DB over the private VNET. Fulls steps on how to set this up are here.

A few things to bear in mind:

  • This requires a standard or premium web app
  • Your VNET must have point-to-site VPN enabled with a Dynamic routing gateway, you may have to recreate your VNET to enable this.
  • The VNET and App Service must be in the same subscription