I have tried to access the secret {{secrets/secrectScope/Key}}
in advanced tab of databricks cluster and it is working fine. But when I try to use the same in databricks init script, it is not working it.
What are the steps to do that?
I have tried to access the secret {{secrets/secrectScope/Key}}
in advanced tab of databricks cluster and it is working fine. But when I try to use the same in databricks init script, it is not working it.
What are the steps to do that?
Another answer is correct regarding the syntax of the secrets reference (so-called "secret paths"), but it won't work for init scripts, although it will work for Spark code itself.
To pass the secret to the init script you need to put the secrets path into the "Environment Variables" sections of the Spark configuration tab, like this:
And after that you can use the variable by name inside the init script:
if [ -n "$SECRET_VAR" ]; then
do_something_with_it
fi
Here are the steps to access secrets in databricks initscript:
Sample ini code:
fs.azure.account.auth.type.chepragen2.dfs.core.windows.net OAuth
fs.azure.account.oauth.provider.type.chepragen2.dfs.core.windows.net org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider
fs.azure.account.oauth2.client.id.chepragen2.dfs.core.windows.net {<!-- -->{secrets/KeyVaultName/ClientID}}
fs.azure.account.oauth2.client.secret.chepragen2.dfs.core.windows.net {<!-- -->{secrets/KeyVaultName/ClientSecret}}
fs.azure.account.oauth2.client.endpoint.chepragen2.dfs.core.windows.net https://login.microsoftonline.com/<Directory_ID>/oauth2/token
For more details, refer Azure Databricks - configure the cluster to read secrets from the secret scope.