How do I assign managed identity to a databricks resource?

Alexa Kiss 0 Reputation points Microsoft Employee
2024-06-12T10:24:08.21+00:00

I have created a linked service from ADF to Databricks cluster, following https://techcommunity.microsoft.com/t5/azure-data-factory-blog/azure-databricks-activities-now-support-managed-identity/ba-p/1922818

I have provided contributor access to the ADF managed identity on ADB. The identity is visible in Databricks workspace among "Service principals"

the following code

from azure.identity import ManagedIdentityCredential

credential = ManagedIdentityCredential(client_id=<ADF_MI_client_ID>) 
# Attempt to get a token to verify the credential
token = credential.get_token('https://management.azure.com/.default')

raises error

ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource. Error: Unexpected response "{'error': 'invalid_request', 'error_description': 'Identity not found'}" ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource. Error: Unexpected response "{'error': 'invalid_request', 'error_description': 'Identity not found'}"CredentialUnavailableError: ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource. Error: Unexpected response "{'error': 'invalid_request', 'error_description': 'Identity not found'}"

File /local_disk0/.ephemeral_nfs/envs/pythonEnv-dee10191-2736-4bc4-8d19-2d7544b07fa7/lib/python3.10/site-packages/azure/identity/_credentials/imds.py:101, in ImdsCredential._request_token(self, *scopes, **kwargs) 100 try: --> 101 token = self._client.request_token(*scopes, headers={"Metadata": "true"}) 102 except HttpResponseError as ex: 103 # 400 in response to a token request indicates managed identity is disabled, 104 # or the identity with the specified client_id is not available

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,045 questions
{count} votes