简体   繁体   中英

is it possible to connect sql server using object id from azure managed identity in data bricks

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM