@@ -117,10 +117,6 @@ To follow along with this article showcasing how to query Azure Cosmos DB data w
117
117
* An Azure Cosmos DB database named ` covid `
118
118
* Two Azure Cosmos DB containers named ` Ecdc ` and ` Cord19 ` loaded with the preceding sample datasets
119
119
120
- You can use the following connection string for testing purpose:
121
-
122
- ` Account=synapselink-cosmosdb-sqlsample;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== `
123
-
124
120
Note that this connection doesn't guarantee performance because this account might be located in remote region compared to your Synapse SQL endpoint.
125
121
126
122
## Explore Azure Cosmos DB data with automatic schema inference
@@ -129,11 +125,16 @@ The easiest way to explore data in Azure Cosmos DB is by using the automatic sch
129
125
130
126
### [ OPENROWSET with key] ( #tab/openrowset-key )
131
127
128
+ > [ IMPORTANT]
129
+ > In the script, replace these values with your own values:
130
+ > - ** your-cosmosdb** - the name of your Cosmos DB account
131
+ > - ** yourcosmosdbkey** - your Cosmos DB account key
132
+
132
133
``` sql
133
134
SELECT TOP 10 *
134
135
FROM OPENROWSET(
135
136
' CosmosDB' ,
136
- ' Account=synapselink -cosmosdb-sqlsample ;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ' ,
137
+ ' Account=your -cosmosdb;Database=covid;Key=yourcosmosdbkey ' ,
137
138
Ecdc) as documents
138
139
```
139
140
@@ -142,12 +143,12 @@ FROM OPENROWSET(
142
143
``` sql
143
144
/* Setup - create server-level or database scoped credential with Azure Cosmos DB account key:
144
145
CREATE CREDENTIAL MyCosmosDbAccountCredential
145
- WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = 's5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ';
146
+ WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = 'yourcosmosdbkey ';
146
147
*/
147
148
SELECT TOP 10 *
148
149
FROM OPENROWSET(
149
150
PROVIDER = ' CosmosDB' ,
150
- CONNECTION = ' Account=synapselink -cosmosdb-sqlsample ;Database=covid' ,
151
+ CONNECTION = ' Account=your -cosmosdb;Database=covid' ,
151
152
OBJECT = ' Ecdc' ,
152
153
SERVER_CREDENTIAL = ' MyCosmosDbAccountCredential'
153
154
) with ( date_rep varchar (20 ), cases bigint , geo_id varchar (6 ) ) as rows
@@ -171,7 +172,7 @@ If you need to explore data from the other container in the same Azure Cosmos DB
171
172
SELECT TOP 10 *
172
173
FROM OPENROWSET(
173
174
' CosmosDB' ,
174
- ' Account=synapselink -cosmosdb-sqlsample ;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ' ,
175
+ ' Account=your -cosmosdb;Database=covid;Key=yourcosmosdbkey ' ,
175
176
Cord19) as cord19
176
177
```
177
178
@@ -197,7 +198,7 @@ These flat JSON documents in Azure Cosmos DB can be represented as a set of rows
197
198
SELECT TOP 10 *
198
199
FROM OPENROWSET(
199
200
' CosmosDB' ,
200
- ' Account=synapselink -cosmosdb-sqlsample ;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ' ,
201
+ ' Account=your -cosmosdb;Database=covid;Key=yourcosmosdbkey ' ,
201
202
Ecdc
202
203
) with ( date_rep varchar (20 ), cases bigint , geo_id varchar (6 ) ) as rows
203
204
```
@@ -207,12 +208,12 @@ FROM OPENROWSET(
207
208
``` sql
208
209
/* Setup - create server-level or database scoped credential with Azure Cosmos DB account key:
209
210
CREATE CREDENTIAL MyCosmosDbAccountCredential
210
- WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = 's5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ';
211
+ WITH IDENTITY = 'SHARED ACCESS SIGNATURE', SECRET = 'yourcosmosdbkey ';
211
212
*/
212
213
SELECT TOP 10 *
213
214
FROM OPENROWSET(
214
215
PROVIDER = ' CosmosDB' ,
215
- CONNECTION = ' Account=synapselink -cosmosdb-sqlsample ;Database=covid' ,
216
+ CONNECTION = ' Account=your -cosmosdb;Database=covid' ,
216
217
OBJECT = ' Ecdc' ,
217
218
SERVER_CREDENTIAL = ' MyCosmosDbAccountCredential'
218
219
) with ( date_rep varchar (20 ), cases bigint , geo_id varchar (6 ) ) as rows
@@ -238,13 +239,13 @@ Once you identify the schema, you can prepare a view on top of your Azure Cosmos
238
239
239
240
``` sql
240
241
CREATE CREDENTIAL MyCosmosDbAccountCredential
241
- WITH IDENTITY = ' SHARED ACCESS SIGNATURE' , SECRET = ' s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ' ;
242
+ WITH IDENTITY = ' SHARED ACCESS SIGNATURE' , SECRET = ' yourcosmosdbkey ' ;
242
243
GO
243
244
CREATE OR ALTER VIEW Ecdc
244
245
AS SELECT *
245
246
FROM OPENROWSET(
246
247
PROVIDER = ' CosmosDB' ,
247
- CONNECTION = ' Account=synapselink -cosmosdb-sqlsample ;Database=covid' ,
248
+ CONNECTION = ' Account=your -cosmosdb;Database=covid' ,
248
249
OBJECT = ' Ecdc' ,
249
250
SERVER_CREDENTIAL = ' MyCosmosDbAccountCredential'
250
251
) with ( date_rep varchar (20 ), cases bigint , geo_id varchar (6 ) ) as rows
@@ -278,7 +279,7 @@ The nested objects and arrays in Azure Cosmos DB are represented as JSON strings
278
279
SELECT TOP 10 *
279
280
FROM OPENROWSET(
280
281
' CosmosDB' ,
281
- ' Account=synapselink -cosmosdb-sqlsample ;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ' ,
282
+ ' Account=your -cosmosdb;Database=covid;Key=yourcosmosdbkey ' ,
282
283
Cord19)
283
284
WITH ( paper_id varchar (8000 ),
284
285
title varchar (1000 ) ' $.metadata.title' ,
@@ -332,7 +333,7 @@ SELECT
332
333
FROM
333
334
OPENROWSET(
334
335
'CosmosDB',
335
- 'Account=synapselink -cosmosdb-sqlsample ;Database=covid;Key=s5zarR2pT0JWH9k8roipnWxUYBegOuFGjJpSjGlR36y86cW0GQ6RaaG8kGjsRAQoWMw1QKTkkX8HQtFpJjC8Hg== ',
336
+ 'Account=your -cosmosdb;Database=covid;Key=yourcosmosdbkey ',
336
337
Cord19
337
338
) WITH ( title varchar(1000) '$.metadata.title',
338
339
authors varchar(max) '$.metadata.authors' ) AS docs
0 commit comments