Connection switching is not happening internally between the service principal certificate key and Managed identity in Synapse notebook for the ADLS account

Venkateswarlu Pottapalli 0 Reputation points Microsoft External Staff
2025-03-19T05:25:00.7533333+00:00

Hi,

I am connecting to the source using the linked service with service principal certificate key in azure synapse notebook. I am able to pull the data in data frame but not able to load the data frame in ADLS Gen2 which is mapped to the same Azure synapse Analytics where I am running the notebook.

The error is like permission issue to the managed identity for the ADLS account.

I am able to load the data using the same notebook if I don't use the connection without service principal certificate. you can refer the two scenarios below.

Scenario 1: (data write is working fine)

step1 : Connect to source ADLS using linked service (managed identity) ----Successful

Step 2 : Create data frame using step1 ----Successful

Step3 : load data in ADLS Gen2 which mapped to Azure synapse Analytics where I am running notebook. --Successful

Scenario 2: (Data write is not working)

step1 : Connect to source ADLS using linked service (Service Principal with certificatekey) --Successful

Step 2 : Create data frame using step1 --Successful

Step3 : load data in ADLS Gen2 which is mapped to Azure synapse Analytics where I am running notebook. --Failed

Based on my understanding it's not able to switch connection from Certificate connected ADLS to managed identity connected ADLS connection.

Please help me what could be the solution for it.

Regards,

Venkat

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,297 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ganesh Gurram 6,050 Reputation points Microsoft External Staff
    2025-03-19T07:06:13.3533333+00:00

    @Venkateswarlu Pottapalli

    It looks like the notebook session continues to use the Service Principal (certificate key) authentication and is not switching to the Managed Identity when writing data to ADLS Gen2.

    To resolve this, please follow these steps:

    Explicitly Configure Spark to Use Managed Identity - Before writing data to ADLS Gen2, ensure your Spark session is set to use the Managed Identity by adding the following configuration:

    storage_account_name = "<your_storage_account_name>"
    
    spark.conf.set(f"fs.azure.account.auth.type.{storage_account_name}.dfs.core.windows.net", "OAuth")
    spark.conf.set(f"fs.azure.account.oauth.provider.type.{storage_account_name}.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.oauth2.MsiTokenProvider")
    
    

    Replace <your_storage_account_name> with your actual ADLS Gen2 storage account name.

    Verify Managed Identity Permissions on ADLS Gen2 - Ensure that your Synapse workspace’s Managed Identity has the Storage Blob Data Contributor role assigned at the storage account level. You can do this by:

    1. Navigating to your ADLS Gen2 Storage Account in the Azure Portal.
    2. Selecting Access Control (IAM) > Add Role Assignment.
    3. Assigning the Storage Blob Data Contributor role to your Synapse Managed Identity.

    For more details refer: Grant permissions to managed identity in Synapse workspace

    I hope this information helps.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues. 

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.