External Data Source
Database Scope Credential
A Database Credential is not mapped to a server login or database user. The credential is used by the database to access to the external location anytime the database is performing an operation that requires access.
List Credentials
Create Master Key
Create a new Master Key, ENCRYPTION
to encrypt the credentials for the external
data source.
-- Optional: Create MASTER KEY if not exists in database:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'P@ssW0rd'
GO
If the master key already exists on the database, you can use:
Create Credential
And the permission of User, Managed Identity, or Service Principle that want to
access data on target external data source should be any role in
Storage Blob Data Owner/Contributor/Reader
roles in order for the application
to access the data via RBAC in Azure Portal.
External Data Source
List Data Source
Create Data Source
CREATE EXTERNAL DATA SOURCE [<external-data-source>]
WITH(
LOCATION = 'abfss://<container>@<storage-account>.dfs.core.windows.net',
CREDENTIAL = <credential-name>,
PUSHDOWN = ON,
TYPE = HADOOP
);
Note
PolyBase data virtualization is used when the EXTERNAL DATA SOURCE
is created with TYPE=HADOOP
.
PUSHDOWN = ON | OFF
is set to ON
by default, meaning the ODBC Driver
can leverage server-side processing for complex queries.
For the LOCATION
, it provide the connectivity protocol and path to the external
data source. See More Supported Protocol
Note
If you want to use Azure AD for access an external data source you can use:
External File Format
List File Format
Create File Format
CREATE EXTERNAL FILE FORMAT <parquet_snappy>
WITH (
FORMAT_TYPE = PARQUET,
DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec'
);
Examples
Example
USE [master];
CREATE LOGIN [username] WITH PASSWORD = 'P@ssW0rd';
GO
USE [database];
CREATE USER [username] FROM LOGIN [username];
GRANT REFERENCES ON DATABASE SCOPED CREDENTIAL::[credential-name] TO [username];
GO