Welcome to Microsoft Q&A! Thanks for posting the question.
Can you please confirm what is the hosting plan for your function app and what IP's you have whitelisted at the MongoDB end? Azure Functions has dedicated IPs only in certain hosting models, see here for details.
As per the error you need to make sure that the function app IP is whitelisted. Some hosting models do not provide a static IP, so you need to whitelist the datacenter IP for the region where your function app is deployed. You can find the datacenter IP's here.