You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**Run-time Support**|Support for read or write by Azure Synapse run-time| ✓ |[Contact Us](mailto:[email protected]?subject=[Enable%20Preview%20Feature]%20SQL%20serverless%20for%20Cosmos%20DB)|
29
-
|**Cosmos DB API support**|API support as a Synapse Link| SQL / Mongo DB | SQL / Mongo DB|
29
+
|**Azure Cosmos DB API support**|API support as a Synapse Link| SQL / MongoDB | SQL / MongoDB|
30
30
|**Object**|Objects such as a table that can be created, pointing directly to Azure Cosmos DB container| View, Table | View |
31
31
|**Read**|Read data from an Azure Cosmos DB container| OLTP / HTAP | HTAP |
32
32
|**Write**|Write data from run-time into an Azure Cosmos DB container| OLTP | n/a |
Copy file name to clipboardExpand all lines: articles/synapse-analytics/synapse-link/how-to-connect-synapse-link-cosmos-db.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Connect to Azure Synapse Link for Cosmos DB
3
-
description: How to connect a Cosmos DB to a Synapse workspace with Azure Synapse Link
2
+
title: Connect to Azure Synapse Link for Azure Cosmos DB
3
+
description: How to connect an Azure Cosmos DB to a Synapse workspace with Azure Synapse Link
4
4
services: synapse-analytics
5
5
author: ArnoMicrosoft
6
6
ms.service: synapse-analytics
@@ -17,9 +17,9 @@ This article describes how to access an Azure Cosmos DB database from Azure Syna
17
17
18
18
## Prerequisites
19
19
20
-
Before you connect an Azure Cosmos DB account to your workspace, you'll need the following:
20
+
Before you connect an Azure Cosmos DB database to your workspace, you'll need the following:
21
21
22
-
* Existing Azure Cosmos DB account or create a new account following this [quickstart](https://docs.microsoft.com/azure/cosmos-db/how-to-manage-database-account)
22
+
* Existing Azure Cosmos DB database or create a new account following this [quickstart](https://docs.microsoft.com/azure/cosmos-db/how-to-manage-database-account)
23
23
* Existing Synapse workspace or create a new workspace following this [quickstart](https://docs.microsoft.com/azure/synapse-analytics/quickstart-create-workspace)
24
24
25
25
## Enable Azure Cosmos DB analytical store
@@ -32,16 +32,16 @@ From your Synapse workspace, select **Launch Synapse Studio**. On the Synapse St
32
32
33
33
## Connect an Azure Cosmos DB database to a Synapse workspace
34
34
35
-
Connecting an Azure Cosmos DB database is done as a linked service. A Cosmos DB linked service enables users to browse and explore data, read, and write from Synapse Spark or SQL into Azure Cosmos DB.
35
+
Connecting an Azure Cosmos DB database is done as a linked service. An Azure Cosmos DB linked service enables users to browse and explore data, read, and write from Synapse Spark or SQL into Azure Cosmos DB.
36
36
37
37
From the Data Object Explorer, you can directly connect to an Azure Cosmos DB database by doing the following steps:
38
38
1. Select ***+*** icon near Data
39
39
2. Select **Connect to external data**
40
-
3. Select the API that you want to connect to: SQL API or MongoDB API
40
+
3. Select the API that you want to connect to: SQL API or API for MongoDB
41
41
4. Select ***Continue***
42
42
5. Name the linked service. The name will be displayed in the Object Explorer and used by Synapse run-times to connect to the database and containers. We recommend using a friendly name.
43
-
6. Select the **Cosmos DB account name** and **database name**
44
-
7. (Optional) If no region is specified, Synapse run-time operations will be routed toward the nearest region where the analytical store is enabled. However, you can set manually which region you want your users to access Cosmos DB analytical store. Select **Additional connection properties** and then **New**. Under **Property Name**, write ***PreferredRegions*** and set the **Value** to the region you want (example: WestUS2, there is no space between words and number)
43
+
6. Select the **Azure Cosmos DB account name** and **database name**
44
+
7. (Optional) If no region is specified, Synapse run-time operations will be routed toward the nearest region where the analytical store is enabled. However, you can set manually which region you want your users to access Azure Cosmos DB Analytical Store. Select **Additional connection properties** and then **New**. Under **Property Name**, write ***PreferredRegions*** and set the **Value** to the region you want (example: WestUS2, there is no space between words and number)
45
45
8. Select ***Create***
46
46
47
47
Azure Cosmos DB databases are visible under the tab **Linked** in the Azure Cosmos DB section. With Azure Cosmos DB, you can differentiate an HTAP enabled container from an OLTP only container through the following icons:
@@ -50,7 +50,7 @@ This scenario is convenient to reuse tables through third-party tools and provid
50
50
51
51
```sql
52
52
%%sql
53
-
-- To select a preferred list of regions in a multi-region Cosmos DB account, add spark.cosmos.preferredRegions '<Region1>,<Region2>' in the config options
53
+
-- To select a preferred list of regions in a multi-region Azure Cosmos DB account, add spark.cosmos.preferredRegions '<Region1>,<Region2>' in the config options
54
54
55
55
createtablecall_center using cosmos.olap options (
In this gesture, you'll write a dataframe into a container. This operation will impact the transactional performance and consume Request Units. Using Azure Cosmos DB transactional performance is ideal for write transactions. Make sure that you replace **YOURDATAFRAME** by the dataframe that you want to write back to.
64
64
65
65
```python
66
-
# Write a Spark DataFrame into a Cosmos DB container
67
-
# To select a preferred list of regions in a multi-region Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
66
+
# Write a Spark DataFrame into an Azure Cosmos DB container
67
+
# To select a preferred list of regions in a multi-region Azure Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
In this gesture, you'll use Spark Streaming capability to load data from a container into a dataframe. The data will be stored in the primary data lake account (and file system) that you connected to the workspace.
94
94
95
-
If the folder */localReadCheckpointFolder* isn't created, it will be automatically created. This operation will impact the transactional performance of Cosmos DB.
95
+
If the folder */localReadCheckpointFolder* isn't created, it will be automatically created. This operation will impact the transactional performance of Azure Cosmos DB.
96
96
97
97
```python
98
-
# To select a preferred list of regions in a multi-region Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
98
+
# To select a preferred list of regions in a multi-region Azure Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
99
99
100
100
dfStream = spark.readStream\
101
101
.format("cosmos.oltp")\
@@ -110,7 +110,7 @@ dfStream = spark.readStream\
110
110
111
111
The equivalent code gesture in **Scala** would be the following code:
112
112
```java
113
-
// To select a preferred list of regions in a multi-region Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
113
+
// To select a preferred list of regions in a multi-region Azure Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
114
114
115
115
val dfStream = spark.readStream.
116
116
format("cosmos.oltp").
@@ -124,10 +124,10 @@ val dfStream = spark.readStream.
124
124
```
125
125
126
126
## Write streaming DataFrame to container
127
-
In this gesture, you'll write a streaming dataframe into the Cosmos DB container you selected. If the folder */localReadCheckpointFolder* isn't created, it will be automatically created. This operation will impact the transactional performance of Cosmos DB.
127
+
In this gesture, you'll write a streaming dataframe into the Azure Cosmos DB container you selected. If the folder */localReadCheckpointFolder* isn't created, it will be automatically created. This operation will impact the transactional performance of Azure Cosmos DB.
128
128
129
129
```python
130
-
# To select a preferred list of regions in a multi-region Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
130
+
# To select a preferred list of regions in a multi-region Azure Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
The equivalent code gesture in **Scala** would be the following code:
146
146
```java
147
-
// To select a preferred list of regions in a multi-region Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
147
+
// To select a preferred list of regions in a multi-region Azure Cosmos DB account, add .option("spark.cosmos.preferredRegions", "<Region1>,<Region2>")
148
148
149
149
val query = dfStream.
150
150
writeStream.
@@ -161,4 +161,4 @@ query.awaitTermination()
161
161
## Next steps
162
162
163
163
*[Learn what is supported between Synapse and Azure Cosmos DB](./concept-synapse-link-cosmos-db-support.md)
164
-
*[Connect to Synapse Link for Cosmos DB](../quickstart-connect-synapse-link-cosmos-db.md)
164
+
*[Connect to Synapse Link for Azure Cosmos DB](../quickstart-connect-synapse-link-cosmos-db.md)
0 commit comments