Skip to content

Commit 3611c80

Browse files
Update develop-storage-files-storage-access-control.md
1 parent 7fd0e0f commit 3611c80

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

articles/synapse-analytics/sql/develop-storage-files-storage-access-control.md

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This article describes the types of credentials you can use and how credential l
2121

2222
## Supported storage authorization types
2323

24-
A user that has logged into a SQL on-demand resource must be authorized to access and query the files in Azure Storage. Three authorization types are supported:
24+
A user that has logged into a SQL on-demand resource must be authorized to access and query the files in Azure Storage if the files are not publicly available. Three authorization types are supported:
2525

2626
- [User Identity](?tabs=user-identity)
2727
- [Shared access signature](?tabs=shared-access-signature)
@@ -42,6 +42,8 @@ You can get an SAS token by navigating to the **Azure portal -> Storage Account
4242
>
4343
> SAS token: ?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-04-18T20:42:12Z&st=2019-04-18T12:42:12Z&spr=https&sig=lQHczNvrk1KoYLCpFdSsMANd0ef9BrIPBNJ3VYEIq78%3D
4444
45+
You need to create database-scoped or server-scoped crednential to enable access using SAS token.
46+
4547
### [User Identity](#tab/user-identity)
4648

4749
**User Identity**, also known as "pass-through", is an authorization type where the identity of the Azure AD user that logged into
@@ -94,7 +96,7 @@ Before accessing the data, the Azure Storage administrator must grant permission
9496

9597
### [Anonymous access](#tab/public-access)
9698

97-
You can access publicly available files placed on Azure storage accounts that allow anonymous access.
99+
You can access publicly available files placed on Azure storage accounts that [allow anonymous access](/azure/storage/blobs/storage-manage-access-to-resources.md).
98100

99101
---
100102

@@ -124,15 +126,14 @@ To query a file located in Azure Storage, your SQL on-demand end point needs a c
124126
- Server-level CREDENTIAL is used for ad-hoc queries executed using `OPENROWSET` function. Credential name must match the storage URL.
125127
- DATABASE SCOPED CREDENTIAL is used for external tables. External table references `DATA SOURCE` with the credential that should be used to access storage.
126128

127-
> [!NOTE]
128-
> There is special server-level CREDENTIAL `UserIdentity` that [forces Azure AD pass-through](#force-azure-ad-pass-through).
129-
130-
Optionally, to allow a user to create or drop a credential, admin can GRANT/DENY ALTER ANY CREDENTIAL permission to a user:
129+
To allow a user to create or drop a credential, admin can GRANT/DENY ALTER ANY CREDENTIAL permission to a user:
131130

132131
```sql
133132
GRANT ALTER ANY CREDENTIAL TO [user_name];
134133
```
135134

135+
Database users who access external storage must have permission to use crednetials.
136+
136137
### Grant permissions to use credential
137138

138139
To use the credential, a user must have `REFERENCES` permission on a specific credential. To grant a `REFERENCES` permission ON a storage_credential for a specific_user, execute:
@@ -162,9 +163,15 @@ Server-level CREDENTIAL name must match the full path to the storage account (an
162163
| Azure Data Lake Storage Gen1 | https | <storage_account>.azuredatalakestore.net/webhdfs/v1 |
163164
| Azure Data Lake Storage Gen2 | https | <storage_account>.dfs.core.windows.net |
164165

166+
> [!NOTE]
167+
> There is special server-level CREDENTIAL `UserIdentity` that [forces Azure AD pass-through](?tabs=user-identity#force-azure-ad-pass-through).
168+
169+
Server-scoped credentials enable access to Azure storage using the following authenticaiton types:
170+
165171
### [Shared access signature](#tab/shared-access-signature)
166172

167-
The following script creates a server-level credential that can be used by `OPENROWSET` function to access any file on Azure storage using SAS token. Create this credential to enable SQL principal that executes `OPENROWSET` function to read files protected with SAS key on the Azure storage that matches URL in credential name.
173+
The following script creates a server-level credential that can be used by `OPENROWSET` function to access any file on Azure storage using SAS token. Create this credential to enable SQL principal that executes `OPENROWSET` function to read files protected
174+
with SAS key on the Azure storage that matches URL in credential name.
168175

169176
Exchange <*mystorageaccountname*> with your actual storage account name, and <*mystorageaccountcontainername*> with the actual container name:
170177

@@ -211,6 +218,7 @@ GO
211218

212219
Database-scoped credentials are used when any principal calls `OPENROWSET` function with `DATA_SOURCE` or selects data from [external table](develop-tables-external-tables.md) that don't access public files. The database scoped credential doesn't need to match the name of storage account because it will be explicitly used in DATA SOURCE that defines the location of storage.
213220

221+
Database-scoped credentials enable access to Azure storage using the following authenticaiton types:
214222

215223
### [Shared access signature](#tab/shared-access-signature)
216224

@@ -250,9 +258,18 @@ Database scoped credential is not required to allow access to publicly available
250258

251259
---
252260

261+
Database scoped credentials are used in external data sources to specify what authentication method will be used to access this storage:
262+
263+
```sql
264+
CREATE EXTERNAL DATA SOURCE mysample
265+
WITH ( LOCATION = 'https://*******.blob.core.windows.net/samples',
266+
CREDENTIAL = <name of database scoped credential>
267+
)
268+
```
269+
253270
## Examples
254271

255-
**External table on publicly available data source**
272+
**Accessing publicly available data source**
256273

257274
Use the following script to create a table that accesses publicly available data source.
258275

@@ -264,10 +281,19 @@ WITH ( LOCATION = 'https://****.blob.core.windows.net/public-access' )
264281
GO
265282

266283
CREATE EXTERNAL TABLE dbo.userPublicData ( [id] int, [first_name] varchar(8000), [last_name] varchar(8000) )
267-
WITH ( LOCATION = 'parquet/user-data/userdata.parquet', DATA_SOURCE = [publicData], FILE_FORMAT = [SynapseParquetFormat] )
284+
WITH ( LOCATION = 'parquet/user-data/*.parquet', DATA_SOURCE = [publicData], FILE_FORMAT = [SynapseParquetFormat] )
268285
```
269286

270-
**External table on data source accessed using credential**
287+
Database user can the content of the files from the data source using external table or OEPNROWSET function that references the data source:
288+
289+
```sql
290+
SELECT TOP 10 * FROM dbo.userPublicData;
291+
GO
292+
SELECT TOP 10 * FROM OPENROWSET(BULK 'parquet/user-data/*.parquet', DATA_SOURCE = [mysample], FORMAT=PARQUET) as rows;
293+
GO
294+
```
295+
296+
**Accessing data source using credential**
271297

272298
Modify the following script to create an external table that accesses Azure storage using SAS token, Azure AD identity of user, or managed identity of workspace.
273299

@@ -290,7 +316,7 @@ CREATE EXTERNAL FILE FORMAT [SynapseParquetFormat] WITH ( FORMAT_TYPE = PARQUET)
290316
GO
291317

292318
CREATE EXTERNAL DATA SOURCE mysample
293-
WITH ( LOCATION = 'https://*******.blob.core.windows.net/samples',
319+
WITH ( LOCATION = 'https://*******.blob.core.windows.net/samples'
294320
-- Uncomment one of these options depending on authentication method that you want to use to access data source:
295321
--,CREDENTIAL = MyIdentity
296322
--,CREDENTIAL = WorkspaceIdentity
@@ -302,6 +328,15 @@ WITH ( LOCATION = 'parquet/user-data/*.parquet', DATA_SOURCE = [mysample], FILE_
302328

303329
```
304330

331+
Database user can the content of the files from the data source using external table or OEPNROWSET function that references the data source:
332+
333+
```sql
334+
SELECT TOP 10 * FROM dbo.userdata;
335+
GO
336+
SELECT TOP 10 * FROM OPENROWSET(BULK 'parquet/user-data/*.parquet', DATA_SOURCE = [mysample], FORMAT=PARQUET) as rows;
337+
GO
338+
```
339+
305340
## Next steps
306341

307342
The articles listed below will help you learn how query different folder types, file types, and create and use views:

0 commit comments

Comments
 (0)