I have a vm running apache2, and setup a simple public load balancer to hit it. This works fine.
However, I'm trying to use this in conjunction with user-defined routes. The reason for this is that I need to know which public ip address my VM uses for accessing the internet, as this vm needs to access another system on another network (this is a very simplified version of our real-life thing, so bear with me).
I have set up an "nva vm" running ubuntu which performs nat translation, and using UDRs I have set my "apache vms" subnet to route thru the nat vm (using destination 0.0.0.0/0 as the destination). When I activate this setup, my apache vm can no longer be accessed using the load balancer.
I can't find any information regarding "special considerations" for using LBs and custom routes, is this not a supported setup?
In brief, the answer is no.
This issue is not caused by Azure. This is a by design behavior. There should be only one effective default route entry configured on a host. In your case, you configure a net VM as the default gateway of your server.
When the server makes a response to the request received from load balancer, according to the route you configured, the packet will be sent to the nat VM, which will cause the connection failure.
If you try to perform a network capture on the server, then you will find that the load balancer doesn't forward the request to the server. It means that Azure won't forward any packet if there is no valid reverse route entry.
In conclusion, the IP ranges need to access the load balancer and the nat VM can not overlap. You should configure the specific route entry instead of the default route.