Share via

Azure Function App (java) can`t connect to MongoDb

2022-01-10T11:21:00.487+00:00

The function app works fine locally. However on Azure, it can not connect to our database with the following message:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.MongoDatabaseFactory]: Factory method 'mongoDbFactory' threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up TXT record for host xxxxxxxxxx.yyyyy.mongodb.net

The MongoDB instance does not have any IP restrictions.
On the console, we can not resolve our MongoDB name through the default server, but it can be resolved through google DNS (8.8.8.8).

163548-image.png

How can we resolve that issue?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


1 answer

Sort by: Most helpful
  1. Александр Шамрай 6 Reputation points
    2022-01-12T07:44:19.18+00:00

    The issue is with the MongoDB driver and Windows OS of Azure Function App. It works fine on Linux OS. For Windows, this solution helps: Failed to import the URI. Unable to look up TXT record for host cluster0-ohzuo.mongodb.net

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.