microsoft / azure-devops-python-api

Azure DevOps Python API
https://docs.microsoft.com/azure/devops/integrate/index?view=azure-devops
MIT License
574 stars 197 forks source link

AttributeError: module 'azure.devops' has no attribute 'connection' #447

Open Landsharkk opened 1 year ago

Landsharkk commented 1 year ago

Trying to use azure.devops to create a dev ops connection string, however it appears azure.devops module doesn't contain a 'connection' or 'connect' attribute.

I'm using azure.devops 6.0.04b

# Get the ADO connection string from azure runbook variable
adoconnectionstring = 'https://dev.azure.com/myname'
# Create a ADO client
client = azure.devops.connect(adoconnectionstring)
# Get the ADO project name from azure runbook variable

AttributeError: module 'azure.devops' has no attribute 'connection'

nechvatalp commented 1 year ago

Hi, could you share the imports? Following piece of code works for me just fine.

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication

# Fill in with your personal access token and org URL
personal_access_token = 'XXX'
organization_url = 'https://dev.azure.com/XXX'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients_v7_1.get_core_client()