A data engineer must read Parquet files from an ADLS Gen2 storage account named contosodatalake. The account is not registered in Unity Catalog. An administrator created a service principal and stored its client secret in the Databricks secret scope storage-secrets. The engineer adds the following code to a notebook. The application ID is already set in the client.id property.
secret = dbutils.secrets.get(scope="storage-secrets", key="sp-client-secret")
acct = "contosodatalake.dfs.core.windows.net"
spark.conf.set(f"fs.azure.account.auth.type.{acct}", "OAuth")
spark.conf.set(f"fs.azure.account.oauth.provider.type.{acct}", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set(f"fs.azure.account.oauth2.client.id.{acct}", "6b1f2c3d-0000-4a5b-9c8d-1e2f3a4b5c6d")
spark.conf.set(f"fs.azure.account.oauth2.client.secret.{acct}", secret)
spark.conf.set(f"fs.azure.account.oauth2.client.endpoint.{acct}", "https://login.microsoftonline.com/<missing-value>/oauth2/token")
Which value should replace <missing-value> in the token endpoint URL?
With notebook-level service principal authentication, Spark uses the OAuth 2.0 client credentials flow to get an access token from Microsoft Entra ID. The client endpoint must therefore point to the tenant where the service principal exists, which is identified by the directory (tenant) ID. The application ID goes in the client.id property, and the storage account name forms part of each property key.
- Not correct: The service principal object ID. The service principal configuration lists the application ID, the directory ID and the client secret as the components used. Its endpoint URL uses the directory ID, not an object ID.
- Correct: The directory (tenant) ID. The endpoint identifies the Microsoft Entra ID tenant where the service principal exists. That tenant issues the access token through the OAuth 2.0 client credentials flow, and the standard configuration places the directory ID in this URL.
- Not correct: The Azure subscription ID. The token comes from the Microsoft Entra ID tenant, so the endpoint takes the directory (tenant) ID. A subscription ID is not one of the service principal values the configuration uses.
- Not correct: The application (client) ID. Spark uses the application ID as the OAuth client ID and reads it from the
oauth2.client.idproperty. - Not correct: The storage account name. Each property key ends with the storage account hostname,
contosodatalake.dfs.core.windows.net. The token endpoint URL takes the directory ID of the tenant instead.