I have a function app attempting to communicate with an Azure VM. Both are in the same VNET through VNET Integration.
The request from the function app to the VM is via http, and the VM does not have a public IP.
Network Security Group rules allow all VNET inbound/outbound. But requests are not going through when requesting via http://[vm-private-ip]/testreq, nor http://[vm-name]/testreq. Errors thrown are "a connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because the connected host has failed to respond." when using IP, and "no such host is known" when using VM name. The function app is using a WebClient with a timeout value of 10 minutes and the error is thrown quickly so it is not a matter of a timeout.
This may have more to do with networking than anything else, but can anyone recommend what else to check for on the VM or otherwise to get this working?
First of all, you need to make sure your function app could work well from your Azure VM when it is deployed to the Azure function. You can deploy your function locally on azure VM to verify this.
Then, verify the connection from the Azure function to your Azure VM. By integrating Functions with an Azure virtual network, your function app is connected to both the internet and your virtual network. You could refer to the steps in that tutorial.
After that, you can use Tcpping tool to test for TCP connectivity to a host and port combination from your Azure function app---Console. If the Tcpping fails, there is a TCP connectivity issue, read this for more troubleshooting details.
For example, I run the following PowerShell commands in the cloud shell to enable IIS for the Azure VM, then the Azure VM will accept the HTTP request with port 80. Then I use tcpping <vm's private IP address> :80
to verify the connection from the Azure function to the Azure VM.
Set-AzVMExtension -ResourceGroupName "rgname" `
-ExtensionName "IIS" `
-VMName "vmname" `
-Location "EastUS" `
-Publisher Microsoft.Compute `
-ExtensionType CustomScriptExtension `
-TypeHandlerVersion 1.8 `
-SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}'