please can some one guide me how to Establish Connection to SQL server using manage identity in data bricks using manage identity object id
I am using following code '''
from azure.core.exceptions import ClientAuthenticationError
from azure.identity import DefaultAzureCredential
# Create a secret client using the DefaultAzureCredential
c_id = DefaultAzureCredential(managed_identity_client_id=client_id)
try:
#https://database.windows.net/.default
#bipp-training-server.database.windows.net/.default
secret = c_id.get_token("https://database.windows.net/.default")
except ClientAuthenticationError as ex:
print(ex.message)
''' and I am getting DefaultAzureCredential failed to retrieve a token from the included credentials
CodePudding user response:
If you want to connect azure managed identity
with azure Databricks
Follow this SO thread by @Alex Ott
Sample code
from databricks import sql from azure.identity import ClientSecretCredential import os tenant_id = 'enter_tenant_id' client_id = 'enter_client_id' client_secret = os.environ['SP_SECRET'] csc = ClientSecretCredential(tenant_id, client_id, client_secret) scope = '2xxxxx/.default' token = csc.get_token(dbx_scope).token
Refer this document for connecting SQL to azure Databricks
CodePudding user response:
Managed identity is associated with virtual machines, and as of right now Databricks doesn't support managed identities for Databricks clusters. So the only choice is to use Service principal authentcation