Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.53k stars 2.76k forks source link

DataFactoryManagementClient does not work in azure-mgmt-datafactory-1.0.0 #16017

Closed mattiethecat closed 2 years ago

mattiethecat commented 3 years ago

Describe the bug In the 1.0.0 release, azure-mgmt-datafactory has this error:

Exception has occurred: AttributeError 'ServicePrincipalCredentials' object has no attribute 'get_token'

To Reproduce Steps to reproduce the behavior:

Install the following: conda create --yes --quiet --name myEnvironment3 python=3.6.8 call activate myEnvironment3 pip install azure-mgmt-datafactory==1.0.0 pip install msrestazure

Create a python file and execute it:

from azure.mgmt.datafactory import DataFactoryManagementClient from azure.common.credentials import ServicePrincipalCredentials from azure.mgmt.datafactory.models import Dataset, PipelineResource

df_name = '...' rg_name = '...' client_id= '...' client_secret='...' tenant_id ='...' subscription_id = '...'

credentials = ServicePrincipalCredentials(client_id=client_id, secret=client_secret, tenant=tenant_id) adf_client = DataFactoryManagementClient(credentials, subscription_id) dflist = adf_client.factories.list_by_resource_group(rg_name) for i in dflist: print (i)

Expected behavior A list of data factories . Error can be avoided by changing the above pip install step to be: pip install azure-mgmt-datafactory==0.14.0

RazvanMorarescu commented 3 years ago

Hi, I had the same issue today, but when triggering an ADF Pipeline.

I found a workaround and these are the changes i made:

  1. Install azure-identity
  2. Instead ServicePrincipalCredentials use ClientSecretCredential from azure.mgmt.datafactory import DataFactoryManagementClient from azure.identity import ClientSecretCredential credentials = ClientSecretCredential(client_id=client_id, client_secret=client_secret, tenant_id=tenant_id) adf_client = DataFactoryManagementClient(credentials, subscription_id)

Hope this helps :)

Also this is the full list of packages i used:

00Kai0 commented 3 years ago

Hi @mattiethecat , This package azure-mgmt-datafactory with version 1.0.0 is created by the next-generation code generator that has lots of importtant breaking changes. You can follow this migration guide to fix your code. If you don't want to use this new version now, you just need to keep verion < 1.0.0.

ghost commented 2 years ago

Hi @mattiethecat. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 2 years ago

Hi @mattiethecat, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.