Hello @Ahsan Habib , In case of the first option I would recommend you to consider using service tags : https://learn.microsoft.com/en-us/azure/virtual-network/service-tags-overview#available-service-tags
Also if you need static, dedicated IP addresses, we recommend App Service Environments (the Isolated tier of App Service plans). { Again this could be an expensive approach as mentioned in point no.2 }
https://learn.microsoft.com/en-us/azure/azure-functions/ip-addresses#dedicated-ip-addresses
For ref : https://www.mongodb.com/blog/post/how-to-integrate-azure-functions-with-mongodb
https://thecodebarbarian.com/getting-started-with-azure-functions-and-mongodb.html