Hi Jorge - as per Mikes comment it would be good to get a little more info so we can help you
Just based on what you wrote already
"function to a server through a VPN using a virtual subnet" - If I assume the function is in Azure and the "virtual subnet" is an Az VNET subnet then you have a VPN gateway either on that VNET or a peered VNET which has a valid route to the server at the other end - then you would need "outbound" connectivity - that is the function needs to be connected using regional vnet integration https://learn.microsoft.com/en-us/azure/azure-functions/functions-networking-options?tabs=azure-cli#virtual-network-integration - Note: the gateway-required option would not be required in the scenario I'm describing.
You should be able to test connectivity (or at least name look up and ping) via the kudu console
REF
https://techcommunity.microsoft.com/t5/apps-on-azure-blog/networking-related-commands-for-azure-app-services/ba-p/392410
Remember that you may need name resolution at the Azure end and, again you'd need a valid route. REF
https://learn.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview#gateways-and-on-premises-connectivity