Azure Cosmos DB¶
Azure Cosmos DB Spark Connector is developed by Microsoft. This connector is in preview and requires Databricks Runtime 3.4 or newer versions.
This page explains how to read and write data to Azure Cosmos DB from Databricks Runtime clusters.
To set up Azure Cosmos DB Spark connector:
- Download the following libraries in the form of jar files, following the links. Please note that you do not need to download dependencies of these libraries.
- com.microsoft.azure:azure-cosmosdb-spark_2.2.0_2.10:0.0.4 or com.microsoft.azure:azure-cosmosdb-spark_2.2.0_2.11:0.0.4. Please use the jar with the Scala version corresponding to the Scala version of your Runtime cluster.
- Upload the downloaded jar files to Databricks following the guidance in Uploading Libraries.
- Attach the uploaded libraries to your cluster.
Using Azure Cosmos DB Spark Connector¶
The following notebook in Scala provides a simple example of how to write data to Cosmos DB and read data from Cosmos DB. See the Azure Cosmos DB Spark Connector project for detailed documentation. The Azure Cosmos DB Spark Connector User Guide, developed by Microsoft, also shows how to use this connector in Python.