Set up required : Key vault
go to settings: Access Configuration, check Azure Role Based Access control under permission model
go to Network: Allow trusted azure services to send request
Create Access connector for Databricks from portal
go to IAM in KV >> Add Role Assignment >> Managed Identity >> select the databricks Access Connector created above >> Add Role as >> Keyvault Secret User
Go To Databricks >> Login as Account Admin
go to Catalog:
Enter Credential name: adb-azkv-credential
IAM Role ARN : Resource id of the access connector which has access to KV. (Open Access connector in portal and click on view Json on over view page. Copy ID)
Click Create.
Provide Access to use the credential from either ui or with code as below
GRANT ACCESS ON SERVICE CREDENTIAL `credential-name` TO `user@xxxxx.onmicrosoft.com`;
once these steps are completed:
go to notebook and test the connection with below code
%pip install azure-keyvault-secrets
from azure.identity import ManagedIdentityCredential
from azure.keyvault.secrets import SecretClient
kv_url = "https://kv-xxxxx.vault.azure.net/"
credential = dbutils.credentials.getServiceCredentialsProvider('credentialname')
secret_client = SecretClient(vault_url=kv_url, credential=credential)
secret_value = secret_client.get_secret("secret-name").value
print(secret_value)


