Hi I am unable to connect to mongodb atlas server from Databricks. I have configured Allow all hosts in network access section and i am able to connect to Mongodb from a Mongo Compass client from my system. I am not sure why it’s not working from Databricks cloud. Below is the code i am using, i have installed the required library as specified in this url:
https://docs.databricks.com/en/_extras/notebooks/source/mongodb.html
val connectionString1 = "mongodb+srv://phanivyr:MyPassword@cluster0.awdeasr.mongodb.net/sample_airbnb?retryWrites=true&w=majority&appName=Cluster0"
val database = "sample_airbnb"
val collection = "listingsAndReviews"
val df = spark.read.format("mongodb").option("database", database).option("spark.mongodb.input.uri", connectionString1).option("collection", collection).load()
df.printSchema()