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
Copy file name to clipboardExpand all lines: articles/synapse-analytics/sql/develop-storage-files-storage-access-control.md
+46-11Lines changed: 46 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ This article describes the types of credentials you can use and how credential l
21
21
22
22
## Supported storage authorization types
23
23
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:
@@ -42,6 +42,8 @@ You can get an SAS token by navigating to the **Azure portal -> Storage Account
42
42
>
43
43
> 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
44
44
45
+
You need to create database-scoped or server-scoped crednential to enable access using SAS token.
46
+
45
47
### [User Identity](#tab/user-identity)
46
48
47
49
**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
94
96
95
97
### [Anonymous access](#tab/public-access)
96
98
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).
98
100
99
101
---
100
102
@@ -124,15 +126,14 @@ To query a file located in Azure Storage, your SQL on-demand end point needs a c
124
126
- Server-level CREDENTIAL is used for ad-hoc queries executed using `OPENROWSET` function. Credential name must match the storage URL.
125
127
- DATABASE SCOPED CREDENTIAL is used for external tables. External table references `DATA SOURCE` with the credential that should be used to access storage.
126
128
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:
131
130
132
131
```sql
133
132
GRANT ALTER ANY CREDENTIAL TO [user_name];
134
133
```
135
134
135
+
Database users who access external storage must have permission to use crednetials.
136
+
136
137
### Grant permissions to use credential
137
138
138
139
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
162
163
| Azure Data Lake Storage Gen1 | https | <storage_account>.azuredatalakestore.net/webhdfs/v1 |
163
164
| Azure Data Lake Storage Gen2 | https | <storage_account>.dfs.core.windows.net |
164
165
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:
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.
168
175
169
176
Exchange <*mystorageaccountname*> with your actual storage account name, and <*mystorageaccountcontainername*> with the actual container name:
170
177
@@ -211,6 +218,7 @@ GO
211
218
212
219
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.
213
220
221
+
Database-scoped credentials enable access to Azure storage using the following authenticaiton types:
**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*FROMdbo.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**
271
297
272
298
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.
273
299
@@ -290,7 +316,7 @@ CREATE EXTERNAL FILE FORMAT [SynapseParquetFormat] WITH ( FORMAT_TYPE = PARQUET)
290
316
GO
291
317
292
318
CREATE EXTERNAL DATA SOURCE mysample
293
-
WITH ( LOCATION ='https://*******.blob.core.windows.net/samples',
319
+
WITH ( LOCATION ='https://*******.blob.core.windows.net/samples'
294
320
-- Uncomment one of these options depending on authentication method that you want to use to access data source:
0 commit comments