I have these following inputs.
1.Endpoint
2.Database
3.Collections
Based on these inputs needs to establish a connection with Azure Cosmos Db from databricks
Tried this approach:
installed importted com.azure.cosmos.spark maven package in databricks cluster with the DBR of 11.3LTS and spark 3.3.0
readCfg = {
"Endpoint": "<endpointurl>",
"Database": "<dbname>",
"Collection": "<collectionname>"
}
readCfg1 = {
"spark.cosmos.accountEndpoint": "<endpointurl>",
"spark.cosmos.database": "<dbname>",
"spark.cosmos.container": "<collectionname>"
}
# Read data from Cosmos DB
df = spark.read.format("com.microsoft.azure.cosmosdb.spark").options(**readCfg).load()
df.show()`
Error Message
getting class not found/assertion error
2
Answers
This code should work. You can modify the query as per requirement.
Try the alternative below code –