I have a MongoDB Cluster deployed in Azure. Normally a MongoDB cluster has at least a couple of mongo router instances (mongos) which is where an application should connect (the application is also hosted in azure).
I want to 'failover' balance the traffic from the application to the mongodb instances. What I mean is that I want to connect my application to one instance an if it fails (and only if it fails) to the other. I don't want my traffic to be balanced with round-robin:
mongorouter1.myinternaldomain.dom:27017: This should be always the the endpoint
mongorouter2.myinternaldomain.dom:27017: This should be the endpoint only if the firstone fails.
mongorouter3.myinternaldomain.dom:27017: This should be the endpoint only if the previous both fail.
I see that this kind of things are managed with the Traffic Manager or with ILB (Internal Load balancer) in Azure. But I have a problem because as I understand the failover balancing is only available with the Traffic manager and that the ILB only allows round-robin.
Because my application is also in Azure I don't want to expose the mongodb ports to the public, so I understand that I can't use the Traffic Manager which is the service that allow failover load balancing.
What should the correct way to implement this?