math-dojo / user-account-service

Microservice for managing the users of the math-dojo platform
1 stars 0 forks source link

Azure Deployed Function does not handle mongodb+srv url #37

Open noce2 opened 4 years ago

noce2 commented 4 years ago

name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: ''


Describe the bug On startup of the deployed azure function, spring fails with an exception about a TXT record not being found for the mongoDb url. Locally, on a desktop, the function could use an srv url and startup appropriately

To Reproduce Steps to reproduce the behavior:

  1. Checkout project on commit cc45ce0
  2. Follow the instructions to build the project, taking care to set the mongoDb url to a replica set style url with mongodb+srv as the protocol
  3. The app will be seen to start up correctly
  4. Modify the MongoDB URI of a deployed function
  5. Send a request to the function and it will respond with a 500 because Spring did not start-up successfully

Expected behavior The function should startup successfully, making use of the appropriate dns lookup to resolve the mongo domain to the records for the 3 replica sets that sit beneath it

Screenshots If applicable, add screenshots to help explain your problem.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.data.mongodb.core.MongoDbFactorySupport]: 
Factory method 'mongoDbFactory' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'mongoClient' defined in class path resource [io/mathdojo/useraccountservice/configuration/DBConfiguration.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: 
Factory method 'mongoClient' threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up TXT record for host nonprodcluster.midgi.azure.mongodb.net

Environment Info (please complete the following information): JVM:

openjdk version "1.8.0_242"
OpenJDK Runtime Environment (Zulu 8.44.0.9-CA-win64) (build 1.8.0_242-b20)
OpenJDK 64-Bit Server VM (Zulu 8.44.0.9-CA-win64) (build 25.242-b20, mixed mode)

Azure Functions Runtime (please complete the following information):**

Additional context Add any other context about the problem here.

rtlefrancois commented 3 years ago

Got kind of the same issue, but using python. Did you figured it out?