Search code examples
pythonazureazure-data-factoryazure-authentication

Using InteractiveBrowserCredential in DataFactoryManagementClient gives error InvalidAuthenticationTokenTenant


I want to start a pipeline run in my Azure Data Factory using python. I have a multi-tenant system, where my Azure account is in one tenant, and the data factory is in the other. I have contributor role to use the data factory and I can use it from the UI.

In python, I use the DataFactoryManagementClient to connect to the ADF using InteractiveBrowserCredential like in the code below, and I get an error saying:

Code: InvalidAuthenticationTokenTenant
Message: The access token is from the wrong issuer ...

Full code:

credential = InteractiveBrowserCredential(additionally_allowed_tenants='*')
adf_client = DataFactoryManagementClient(credential=credential, subscription_id='<subscription-id>')
run_response = adf_client.pipelines.create_run(
    resource_group_name=rg_name, 
    factory_name=adf_name, 
    pipeline_name=pipeline_name, 
    parameters={'counter': '100'})

I know that I can create a service principal, give it access to the data factory and use it for creating a pipeline run, but in my org, getting a service principal can take some time because it has to come from the IT.

Can I not use DataFactoryManagementClient with a token from a different tenant at all? Is there an alternative to creating a service principal?


Solution

  • When you create InteractiveBrowserCredential, you can specify tenant_id in the ctor.

    Did you have a chance to try that?

    (I am working in Azure SDK team in Microsoft)