<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83920#M37069</link>
    <description>&lt;P&gt;Ok, so unfortunately&amp;nbsp;&lt;SPAN&gt;using User Assigned Managed Identity to read/write from ADLS Gen2 inside a notebook is not directly supported. Your best bet is to use regular service principal or switch to unity catalog.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2024 12:26:26 GMT</pubDate>
    <dc:creator>szymon_dybczak</dc:creator>
    <dc:date>2024-08-22T12:26:26Z</dc:date>
    <item>
      <title>How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83909#M37063</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;I'm trying to figure out if we can switch from Entra ID SPN's to User Assigned Managed Indentities and everything works except I can't figure out how to access the lake files from python notebook.&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;I've tried with below code and was running it on a cluster as Managed Identity but basically I was getting the same error as when I've tried to run from any differetn cluster:&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;spark.conf.set("fs.azure.account.auth.type.storageaccount.dfs.core.windows.net", "OAuth")&lt;/DIV&gt;&lt;DIV&gt;spark.conf.set("fs.azure.account.oauth.provider.type.storageaccount.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.oauth2.ManagedIdentityTokenProvider")&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;df = spark.read.csv("abfss://mylakecontainer@storageaccount.dfs.core.windows.net/path/to/csv/file.csv")&lt;/DIV&gt;&lt;DIV&gt;df.show()&lt;/DIV&gt;&lt;DIV&gt;but I get an error:&lt;/DIV&gt;&lt;DIV&gt;IllegalArgumentException: Failed to initialize org.apache.hadoop.fs.azurebfs.oauth2.ManagedIdentityTokenProvider&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;I could not find any example online where Managed Identity is used to get access to the lake&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;Then I've decided to try different approach as I've had only reader sole assigned to that Managed Identity so it should be possible to for example print some properties:&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;from azure.identity import DefaultAzureCredential&lt;/DIV&gt;&lt;DIV&gt;from azure.identity import ManagedIdentityCredential&lt;/DIV&gt;&lt;DIV&gt;from azure.storage.blob import BlobServiceClient&lt;/DIV&gt;&lt;DIV&gt;from azure.mgmt.storage import StorageManagementClient&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;subscription_id = "111-111-111-111"&lt;/DIV&gt;&lt;DIV&gt;resource_group_name = "rmy-rg"&lt;/DIV&gt;&lt;DIV&gt;storage_account_name = "mystorage"&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;account_url = f"https://{storage_account_name}.blob.core.windows.net"&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;credential = ManagedIdentityCredential()&lt;/DIV&gt;&lt;DIV&gt;storage_client = StorageManagementClient(credential, subscription_id)&lt;/DIV&gt;&lt;DIV&gt;storage_account = storage_client.storage_accounts.get_properties(&lt;/DIV&gt;&lt;DIV&gt;resource_group_name, storage_account_name&lt;/DIV&gt;&lt;DIV&gt;)&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;print("Storage Account Properties:")&lt;/DIV&gt;&lt;DIV&gt;print(f"Name: {storage_account.name}")&lt;/DIV&gt;&lt;DIV&gt;print(f"Location: {storage_account.location}")&lt;/DIV&gt;&lt;DIV&gt;print(f"Kind: {storage_account.kind}")&lt;/DIV&gt;&lt;DIV&gt;print(f"SKU: {storage_account.sku.name}")&lt;/DIV&gt;&lt;DIV&gt;print(f"Primary Location: {storage_account.primary_location}")&lt;/DIV&gt;&lt;DIV&gt;print(f"Status of Primary: {storage_account.status_of_primary}")&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;And even with my cluster having Access Mode set to "Assigned" and that assignee is the Managed Identity, when I run the above code I get the error:&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;HttpResponseError: (AuthorizationFailed) The client '1f945563-4de8-44a0-a979-2c4e4540ad4c' with object id '1f945563-4de8-44a0-a979-2c4e4540ad4c' does not have authorization to perform action 'Microsoft.Storage/storageAccounts/read' over scope '/subscriptions/111-111-11/resourceGroups/my-rg/providers/Microsoft.Storage/storageAccounts/mystorage' or the scope is invalid. If access was recently granted, please refresh your credentials.&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;This client ID&amp;nbsp;1f945563-4de8-44a0-a979-2c4e4540ad4c is the dbmanagedidentity (enterprise application default one) and not my User Assigned Managed Identity which is added to the workspace as the SPN. Why the job running on that cluser in assigned mode still not using my managed identity?&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;In the last&amp;nbsp; second, I've decided to use&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;client_id = "my-umi-client-id"&lt;/DIV&gt;&lt;DIV&gt;credential = DefaultAzureCredential(managed_identity_client_id=client_id)&lt;/DIV&gt;&lt;DIV&gt;But then I get the error:&lt;/DIV&gt;&lt;DIV&gt;ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;WARNING:azure.identity._credentials.chained:DefaultAzureCredential failed to retrieve a token from the included credentials.&lt;/DIV&gt;&lt;DIV&gt;Attempted credentials:&lt;/DIV&gt;&lt;DIV&gt;EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.&lt;/DIV&gt;&lt;DIV&gt;Visit &lt;A href="https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot" target="_blank"&gt;https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot&lt;/A&gt; to troubleshoot this issue.&lt;/DIV&gt;&lt;DIV&gt;ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource. Error: Unexpected response "{'error': 'invalid_request', 'error_description': 'Identity not found'}"&lt;/DIV&gt;&lt;DIV&gt;SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.&lt;/DIV&gt;&lt;DIV&gt;AzureCliCredential: Azure CLI not found on path&lt;/DIV&gt;&lt;DIV&gt;AzurePowerShellCredential: PowerShell is not installed&lt;/DIV&gt;&lt;DIV&gt;AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit &lt;A href="https://aka.ms/azure-dev" target="_blank"&gt;https://aka.ms/azure-dev&lt;/A&gt; for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'.&lt;/DIV&gt;&lt;DIV&gt;To mitigate this issue, please refer to the troubleshooting guidelines here at &lt;A href="https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot" target="_blank"&gt;https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot&lt;/A&gt;.&lt;/DIV&gt;&lt;DIV&gt;but this managed Identity is assigned to that cluster...&lt;/DIV&gt;&lt;DIV&gt;What I'm doing wrong here?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Azure Databricks Service does not have Identity option and if I go to managed resource group of the workspace, there is just plethora of VM's so I guess this is not the correct way to assign User Managed Identity to the cluster...&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Aug 2024 10:31:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83909#M37063</guid>
      <dc:creator>Filip</dc:creator>
      <dc:date>2024-08-22T10:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83913#M37065</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/116841"&gt;@Filip&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It's obsolete way of configuring access to storage account. Nowadays you should use UC and storage credentials and external location to configure access to storage account.&amp;nbsp;&lt;/P&gt;&lt;P&gt;A storage credential is a securable object representing an Azure managed identity or Microsoft Entra ID service principal. Once a storage credential is created access to it can be granted to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-principal" target="_blank" rel="noopener"&gt;principals&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(users and groups).Storage credentials are primarily used to create&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-external-locations" target="_blank" rel="noopener"&gt;external locations&lt;/A&gt;, which scope access to a specific storage path&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-storage-credentials" target="_blank" rel="noopener"&gt;Storage credentials - Azure Databricks - Databricks SQL | Microsoft Learn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 10:58:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83913#M37065</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-08-22T10:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83917#M37067</link>
      <description>&lt;P&gt;Yea I'm aware of that UC is fixing that but I'm not on UC yet and wanted to know if it is even possible to use our own user assigned managed identity and assign it instead of using built-in one as it looks it os not really possible for some reason.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 12:17:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83917#M37067</guid>
      <dc:creator>Filip</dc:creator>
      <dc:date>2024-08-22T12:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83920#M37069</link>
      <description>&lt;P&gt;Ok, so unfortunately&amp;nbsp;&lt;SPAN&gt;using User Assigned Managed Identity to read/write from ADLS Gen2 inside a notebook is not directly supported. Your best bet is to use regular service principal or switch to unity catalog.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 12:26:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/83920#M37069</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-08-22T12:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/100876#M40455</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I can be accessed with the following code.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;storageAccountName = "my-storage-account-name"
applicationClientId = "my-umi-client-id"
aadDirectoryId = "my-entra-tenant-id"
containerName = "my-lake-container"

spark.conf.set("fs.azure.account.auth.type", "OAuth")
spark.conf.set("fs.azure.account.oauth.provider.type","org.apache.hadoop.fs.azurebfs.oauth2.MsiTokenProvider")
spark.conf.set("fs.azure.account.oauth2.msi.tenant", aadDirectoryId)
spark.conf.set("fs.azure.account.oauth2.client.id", applicationClientId)

df = spark.read.csv("abfss://"+containerName+"@"+storageAccountName+".dfs.core.windows.net/hello.csv")
df.show()&lt;/LI-CODE&gt;&lt;P&gt;I too would like to change to UC but can't take the time to do so...&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 09:00:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/100876#M40455</guid>
      <dc:creator>kuniteru</dc:creator>
      <dc:date>2024-12-04T09:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/119252#M45820</link>
      <description>&lt;P&gt;hi. could you tell me what were the cluster settings you used for this one.&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 18:42:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/119252#M45820</guid>
      <dc:creator>Ankitbarlota92</dc:creator>
      <dc:date>2025-05-14T18:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/136196#M50513</link>
      <description>&lt;P&gt;Best option is to use "External Locations" and "Storage Credentials" under "Unity Catalog". This avoids tons of problems.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If Unity Catalog is not possible, only way to achieve this I was able to verify is&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;When you deploy a Databricks workspace, a user-assigned &lt;EM&gt;dbManagedIdentity&lt;/EM&gt;&amp;nbsp;is created in background. Not sure if this only happens in non-VNET injected workspaces or for all setups (pending to check)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Coffee77_0-1761572795274.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/21064i4E7D6F3B1231BAF4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Coffee77_0-1761572795274.png" alt="Coffee77_0-1761572795274.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Previous &lt;EM&gt;dbManagedIdentity&lt;/EM&gt; is then associated to VMs making up the cluster. So, if you assign proper roles to this managed identity over ADLS, it turns out &lt;EM&gt;DefaultAzureCredentials&lt;/EM&gt; gets this "identity" (checked in access token payload and code on my own) and the code pasted above really works. VMs are using this managed identity to access ADLS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; but (I think) nothing to do with Azure Databricks Connector.&lt;/P&gt;&lt;P&gt;Check here how user-assigned managed identity is assigned to VMs&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Coffee77_1-1761572829188.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/21065i6B627F423F425AE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Coffee77_1-1761572829188.png" alt="Coffee77_1-1761572829188.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 13:54:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/136196#M50513</guid>
      <dc:creator>Coffee77</dc:creator>
      <dc:date>2025-10-27T13:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Assign User Managed Identity to DBR Cluster so I can use it for quering ADLSv2?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/136198#M50514</link>
      <description>&lt;P&gt;Besides, this only works in dedicated clusters, non working on shared ones. Why? No idea at all. Latest case, IMDS (Internal Metadata Service) used by Azure to inject token endpoint inside resources as a unique secure and valid channel to get tokens for managed identities is not created or not accessible. So, we get this error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Coffee77_2-1761573765940.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/21066i99C1A87653A617BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Coffee77_2-1761573765940.png" alt="Coffee77_2-1761573765940.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 14:03:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-assign-user-managed-identity-to-dbr-cluster-so-i-can-use/m-p/136198#M50514</guid>
      <dc:creator>Coffee77</dc:creator>
      <dc:date>2025-10-27T14:03:34Z</dc:date>
    </item>
  </channel>
</rss>

