An Azure service that provides a hybrid, multi-cloud management platform for APIs.
Hi @Simon Zhang,
The documentation in question that you're looking for is https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-secure-credentials-with-tokenlibrary?pivots=programming-language-python. It provides various python snippets using the mssparkutils package. You can utilize this library to manage credentials and access tokens. For example,
from mssparkutils.credentials import getToken
# Get the token for the storage account
token = getToken("https://storage.azure.com/")
# Use the token to access the storage account
spark.conf.set("fs.azure.account.auth.type.<storage-account-name>.dfs.core.windows.net", "OAuth")
spark.conf.set("fs.azure.account.oauth.provider.type.<storage-account-name>.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set("fs.azure.account.oauth2.client.id.<storage-account-name>.dfs.core.windows.net", token["accessToken"])
In order to leverage the getToken method, your resource needs to have a system identity assigned to it and that identity should have RBAC roles to your Synapse resource; see https://learn.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-understand-what-role-you-need for more details.