{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}