Skip to content

Commit 366c47c

Browse files
authored
Merge pull request #115929 from jovanpop-msft/patch-172
Adding database scoped credentials in quickstart-sql-on-demand.md
2 parents 21babf8 + 61a708a commit 366c47c

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

articles/synapse-analytics/quickstart-sql-on-demand.md

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,21 @@ Use the following query, changing `mydbname` to a name of your choice:
5555
CREATE DATABASE mydbname
5656
```
5757

58-
### Create credentials
58+
### Create data source
5959

60-
To run queries using SQL on-demand, create credentials for SQL on-demand to use to access files in storage.
61-
62-
> [!NOTE]
63-
> In order to successfully run samples in this section you have to use an SAS token.
64-
>
65-
> To start using SAS tokens you have to drop the UserIdentity which is explained in the following [article](sql/develop-storage-files-storage-access-control.md#disable-forcing-azure-ad-pass-through).
66-
>
67-
> SQL on-demand by default always uses AAD pass-through.
68-
69-
For more information on how to manage storage access control, see the[Control storage account access for SQL on-demand ](sql/develop-storage-files-storage-access-control.md) article.
70-
71-
Execute the following code snippet to create credentials used in samples in this section:
60+
To run queries using SQL on-demand, create data source that SQL on-demand can use use to access files in storage.
61+
Execute the following code snippet to create data source used in samples in this section:
7262

7363
```sql
7464
-- create credentials for containers in our demo storage account
75-
IF EXISTS
76-
(SELECT * FROM sys.credentials
77-
WHERE name = 'https://sqlondemandstorage.blob.core.windows.net')
78-
DROP CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net]
79-
GO
80-
81-
CREATE CREDENTIAL [https://sqlondemandstorage.blob.core.windows.net]
65+
CREATE DATABASE SCOPED CREDENTIAL sqlondemand
8266
WITH IDENTITY='SHARED ACCESS SIGNATURE',
8367
SECRET = 'sv=2018-03-28&ss=bf&srt=sco&sp=rl&st=2019-10-14T12%3A10%3A25Z&se=2061-12-31T12%3A10%3A00Z&sig=KlSU2ullCscyTS0An0nozEpo4tO5JAgGBvw%2FJX2lguw%3D'
8468
GO
69+
CREATE EXTERNAL DATA SOURCE SqlOnDemandDemo WITH (
70+
LOCATION = 'https://sqlondemandstorage.blob.core.windows.net',
71+
CREDENTIAL = sqlondemand
72+
);
8573
```
8674

8775
## Query CSV files
@@ -96,8 +84,9 @@ The following query shows how to read a CSV file that doesn't contain a header r
9684
SELECT TOP 10 *
9785
FROM OPENROWSET
9886
(
99-
BULK 'https://sqlondemandstorage.blob.core.windows.net/csv/population/*.csv'
100-
, FORMAT = 'CSV'
87+
BULK 'csv/population/*.csv',
88+
DATA_SOURCE = 'SqlOnDemandDemo',
89+
FORMAT = 'CSV', PARSER_VERSION = '2.0'
10190
)
10291
WITH
10392
(
@@ -124,8 +113,9 @@ The following sample shows the automatic schema inference capabilities for query
124113
SELECT COUNT_BIG(*)
125114
FROM OPENROWSET
126115
(
127-
BULK 'https://sqlondemandstorage.blob.core.windows.net/parquet/taxi/year=2017/month=9/*.parquet'
128-
, FORMAT='PARQUET'
116+
BULK 'parquet/taxi/year=2017/month=9/*.parquet',
117+
DATA_SOURCE = 'SqlOnDemandDemo',
118+
FORMAT='PARQUET'
129119
) AS nyc
130120
```
131121

@@ -164,7 +154,8 @@ SELECT
164154
, jsonContent
165155
FROM OPENROWSET
166156
(
167-
BULK 'https://sqlondemandstorage.blob.core.windows.net/json/books/*.json'
157+
BULK 'json/books/*.json',
158+
DATA_SOURCE = 'SqlOnDemandDemo'
168159
, FORMAT='CSV'
169160
, FIELDTERMINATOR ='0x0b'
170161
, FIELDQUOTE = '0x0b'

0 commit comments

Comments
 (0)