Skip to content

Commit

Permalink
Merge pull request #155 from microsoft/v1.8.2
Browse files Browse the repository at this point in the history
Adding Synapse Spark Authentication Option
  • Loading branch information
prdpsvs authored Apr 15, 2024
2 parents 8549bb1 + de75bac commit 0b3a906
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbt/adapters/fabric/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.1"
version = "1.8.2"
25 changes: 25 additions & 0 deletions dbt/adapters/fabric/fabric_connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dbt.adapters.fabric.fabric_credentials import FabricCredentials

AZURE_CREDENTIAL_SCOPE = "https://database.windows.net//.default"
SYNAPSE_SPARK_CREDENTIAL_SCOPE = "DW"
_TOKEN: Optional[AccessToken] = None
AZURE_AUTH_FUNCTION_TYPE = Callable[[FabricCredentials], AccessToken]

Expand Down Expand Up @@ -87,6 +88,29 @@ def convert_access_token_to_mswindows_byte_string(token: AccessToken) -> bytes:
return convert_bytes_to_mswindows_byte_string(value)


def get_synapse_spark_access_token(credentials: FabricCredentials) -> AccessToken:
"""
Get an Azure access token by using mspsarkutils
Parameters
-----------
credentials: FabricCredentials
Credentials.
Returns
-------
out : AccessToken
The access token.
"""
from notebookutils import mssparkutils

aad_token = mssparkutils.credentials.getToken(SYNAPSE_SPARK_CREDENTIAL_SCOPE)
expires_on = int(time.time() + 4500.0)
token = AccessToken(
token=aad_token,
expires_on=expires_on,
)
return token


def get_cli_access_token(credentials: FabricCredentials) -> AccessToken:
"""
Get an Azure access token using the CLI credentials
Expand Down Expand Up @@ -152,6 +176,7 @@ def get_environment_access_token(credentials: FabricCredentials) -> AccessToken:
"cli": get_cli_access_token,
"auto": get_auto_access_token,
"environment": get_environment_access_token,
"synapsespark": get_synapse_spark_access_token,
}


Expand Down

0 comments on commit 0b3a906

Please sign in to comment.