{"id":1922,"library":"azure-devops","title":"Azure DevOps Python API Client","description":"The `azure-devops` library provides a Pythonic wrapper around the Azure DevOps REST APIs, enabling programmatic interaction with Azure DevOps Services and Azure DevOps Server. It allows developers to automate tasks, manage resources like work items, repositories, pipelines, and more. The library has a frequent release cadence, often releasing beta versions to align with the latest Azure DevOps API versions, currently focusing on 7.x APIs.","status":"active","version":"7.1.0b4","language":"python","source_language":"en","source_url":"https://github.com/microsoft/azure-devops-python-api","tags":["azure","devops","microsoft","api-client","automation"],"install":[{"cmd":"pip install azure-devops","lang":"bash","label":"Install latest stable/beta"}],"dependencies":[{"reason":"Core dependency for handling REST responses and authentication models like BasicAuthentication.","package":"msrest","optional":false},{"reason":"Provides various Azure Active Directory authentication flows (e.g., InteractiveBrowserCredential) as an alternative to Personal Access Tokens.","package":"azure-identity","optional":true}],"imports":[{"note":"The primary Connection class resides in the 'connection' submodule.","wrong":"from azure.devops import Connection","symbol":"Connection","correct":"from azure.devops.connection import Connection"},{"note":"BasicAuthentication is provided by the 'msrest' library, a core dependency, not directly from 'azure.devops'.","wrong":"from azure.devops.authentication import BasicAuthentication","symbol":"BasicAuthentication","correct":"from msrest.authentication import BasicAuthentication"}],"quickstart":{"code":"import os\nfrom azure.devops.connection import Connection\nfrom msrest.authentication import BasicAuthentication\nimport pprint\n\n# Retrieve organization URL and Personal Access Token from environment variables\norganization_url = os.environ.get('AZURE_DEVOPS_ORG_URL', 'https://dev.azure.com/YOUR_ORGANIZATION')\npersonal_access_token = os.environ.get('AZURE_DEVOPS_PAT', 'YOUR_PERSONAL_ACCESS_TOKEN')\n\nif not organization_url or organization_url == 'https://dev.azure.com/YOUR_ORGANIZATION':\n    print(\"Please set the AZURE_DEVOPS_ORG_URL environment variable or update the placeholder.\")\n    exit(1)\n\nif not personal_access_token or personal_access_token == 'YOUR_PERSONAL_ACCESS_TOKEN':\n    print(\"Please set the AZURE_DEVOPS_PAT environment variable or update the placeholder.\")\n    exit(1)\n\n# Create a connection to the organization\ncredentials = BasicAuthentication('', personal_access_token)\nconnection = Connection(base_url=organization_url, creds=credentials)\n\n# Get a client (the 'core' client provides access to projects, teams, etc.)\ncore_client = connection.clients.get_core_client()\n\ntry:\n    # Get the first page of projects\n    get_projects_response = core_client.get_projects()\n    print(\"Successfully connected to Azure DevOps. Projects:\")\n    index = 0\n    while get_projects_response is not None:\n        for project in get_projects_response.value:\n            pprint.pprint(f\"[{index}] {project.name}\")\n            index += 1\n        if get_projects_response.continuation_token:\n            get_projects_response = core_client.get_projects(continuation_token=get_projects_response.continuation_token)\n        else:\n            get_projects_response = None\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to connect to an Azure DevOps organization using a Personal Access Token (PAT) and retrieve a list of projects. It is recommended to store sensitive information like PATs in environment variables for security."},"warnings":[{"fix":"Review the GitHub releases and official Azure DevOps REST API documentation for the target API version. Regenerate client code if you are maintaining a fork, or adapt your calls to match the updated client methods and data models.","message":"The library closely tracks Azure DevOps REST API versions. Upgrading to a new major library version (e.g., from 6.x to 7.x) may introduce breaking changes in API client method signatures, return types, or data shapes, requiring code adjustments to align with the new underlying REST API version.","severity":"breaking","affected_versions":"6.x, 7.x and above"},{"fix":"Always pass `BasicAuthentication('', personal_access_token)`. If encountering 401/403 errors on redirects, investigate the underlying HTTP client behavior or consider alternative authentication methods like those provided by `azure-identity`.","message":"When using Personal Access Tokens (PATs) with `BasicAuthentication`, ensure the username is an empty string and the PAT is passed as the password. Issues can arise if PATs are not correctly formatted or if underlying HTTP clients in redirects strip authentication headers, leading to 401/403 errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your library version is up-to-date. If issues persist, inspect the raw JSON response from the Azure DevOps API (e.g., via `requests` directly) and the library's client code for the specific API to identify discrepancies. Report issues to the maintainers if it's a library bug.","message":"The library might encounter deserialization errors (e.g., incorrect type casting from `int` to `float` or unexpected JSON structures) when processing API responses, especially with new or evolving API endpoints or specific data fields.","severity":"gotcha","affected_versions":"All versions, notably seen in 5.1.0b7, 6.0.0b2, 7.1.0b3 for property type fixes."},{"fix":"Check the API versions supported by your Azure DevOps Server instance. If necessary, use an older `azure-devops` client library version or explicitly set the `api-version` parameter in your API calls to a version compatible with your server.","message":"Running against Azure DevOps Server (on-premises) might lead to compatibility issues if the client library utilizes preview API versions (e.g., `7.1-preview.1`) that are not yet supported by your specific server installation, potentially causing unexpected errors or missing functionality.","severity":"gotcha","affected_versions":"All versions, especially when using beta client versions with older Azure DevOps Server instances."},{"fix":"Identify the missing module from the error message and install it explicitly (e.g., `pip install openpyxl`). Consult relevant documentation or examples for the feature you are trying to use to determine necessary optional dependencies.","message":"Certain functionalities (e.g., working with Excel files for migration, advanced work item field manipulation) may require additional, implicitly optional dependencies (e.g., `openpyxl`). A `ModuleNotFoundError` or `ImportError` typically indicates a missing optional package for your specific use case.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'7':70 'align':59 'allow':33 'api':4,20,65,72,77 'api-cli':76 'around':15 'autom':36,79 'azur':1,8,17,25,29,63,73 'azure-devop':7 'beta':56 'cadenc':53 'client':5,78 'current':67 'develop':34 'devop':2,9,18,26,30,64,74 'enabl':21 'focus':68 'frequent':51 'interact':23 'item':42 'latest':62 'librari':10,48 'like':40 'manag':38 'microsoft':75 'often':54 'pipelin':44 'programmat':22 'provid':11 'python':3,13 'releas':52,55 'repositori':43 'resourc':39 'rest':19 'server':31 'servic':27 'task':37 'version':57,66 'work':41 'wrapper':14 'x':71","created_at":"2026-04-09T18:35:54.352218+00:00","updated_at":"2026-04-15T22:12:31.482675+00:00","problems":[{"fix":"Ensure the `azure-devops` library is installed in the active Python environment. If using Azure Pipelines, verify `requirements.txt` includes `azure-devops` and `pip install -r requirements.txt` is run, or explicitly install it using `pip install azure-devops`.","cause":"The `azure-devops` package or its dependencies are not installed, or the Python environment running the script does not have access to the installed packages.","error":"ModuleNotFoundError: No module named 'azure.devops'"},{"fix":"Verify that the base URL for the `VssConnection` uses `https://` (e.g., `https://dev.azure.com/{organization}`) and that the API endpoint and HTTP method are correct for the intended operation. For example, creating a work item usually requires a POST request to a specific endpoint.","cause":"This error typically indicates that the HTTP method used (e.g., POST, GET) is not allowed for the requested resource, or the URL used to access the Azure DevOps API is incorrect, often due to using HTTP instead of HTTPS.","error":"vsts.exceptions.VstsClientRequestError: Operation returned an invalid status code of 405"},{"fix":"To retrieve work items using a WIQL query, use the `query_by_wiql` method of the `WorkItemTrackingClient` with a `Wiql` object, then use the returned work item references to fetch the full work items. To get work items by ID, pass a list of IDs to `get_work_items(ids=desired_ids)`.","cause":"The `get_work_items` method of the `WorkItemTrackingClient` does not accept a direct `query` keyword argument. Instead, it expects a list of work item IDs or requires a separate WIQL (Work Item Query Language) client to execute queries.","error":"TypeError: get_work_items() got an unexpected keyword argument 'query'"},{"fix":"Generate a new Personal Access Token in Azure DevOps with the necessary scopes (e.g., Work Items, Code, Build, Release), ensuring it has not expired. Update the PAT in your script or environment variables. Also, confirm the PAT is being passed correctly to `BasicAuthentication` or `PersonalAccessToken`.","cause":"The Personal Access Token (PAT) used for authentication is expired, revoked, has insufficient permissions, or is incorrectly provided.","error":"AzureDevopsServiceError: Failed to authenticate using the supplied token."},{"fix":"Access the client using `connection.get_client(BuildClient)` (or the respective client for your desired service, e.g., `WorkItemTrackingClient`, `GitClient`) after importing it from the correct versioned module (e.g., `from azure.devops.v7_1.build.build_client import BuildClient`).","cause":"Specific clients like `build_client` are not directly attributes of the `VssConnection` object. Instead, they must be retrieved using the `get_client()` method with the appropriate client class from the `azure-devops` SDK.","error":"AttributeError: 'VssConnection' object has no attribute 'build_client'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"7.1.0b4","cli_name":"az","cli_version":"sh: 1: az: not found","type":"library","homepage":"https://docs.microsoft.com/en-us/azure/devops/python/api/overview","github":"https://github.com/microsoft/azure-devops-python-api","docs":null,"changelog":null,"pypi":"https://pypi.org/project/azure-devops/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["azure","devops","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}