azure-devops-python-api icon indicating copy to clipboard operation
azure-devops-python-api copied to clipboard

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

Open Landsharkk opened this issue 2 years ago • 1 comments

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'

Landsharkk avatar Mar 11 '23 01:03 Landsharkk

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()

nechvatalp avatar Apr 29 '23 17:04 nechvatalp