{"id":2879,"library":"azure-mgmt-devtestlabs","title":"Azure DevTest Labs Management","description":"Microsoft Azure DevTestLabs Management Client Library for Python, currently at version 9.0.0. This library provides programmatic access to manage Azure DevTest Labs resources, including labs, virtual machines, custom images, and schedules. Azure SDK libraries typically follow a regular release schedule, with updates for new features and bug fixes.","status":"active","version":"9.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/devtestlabs/azure-mgmt-devtestlabs","tags":["azure","management","devtestlabs","cloud","sdk"],"install":[{"cmd":"pip install azure-mgmt-devtestlabs","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for authentication using Azure Active Directory credentials, such as DefaultAzureCredential.","package":"azure-identity"},{"reason":"Provides core functionalities for Azure SDK clients, including shared exceptions and HTTP pipeline.","package":"azure-core"}],"imports":[{"note":"In V2 of the Azure SDK for Python, the main management client class name was simplified from `DevTestLabsManagementClient` to `DevTestLabsClient`.","wrong":"from azure.mgmt.devtestlabs import DevTestLabsManagementClient","symbol":"DevTestLabsClient","correct":"from azure.mgmt.devtestlabs import DevTestLabsClient"},{"note":"This is the recommended credential type for most applications, attempting to authenticate via various common methods.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.devtestlabs import DevTestLabsClient\n\n# Set your Azure Subscription ID as an environment variable\n# E.g., export AZURE_SUBSCRIPTION_ID=\"<your-subscription-id>\"\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set.\")\n\n# Authenticate using DefaultAzureCredential\n# This will try various authentication methods, like environment variables,\n# managed identity, Azure CLI, VS Code, etc.\ncredential = DefaultAzureCredential()\n\n# Create a DevTestLabsClient\nclient = DevTestLabsClient(credential, subscription_id)\n\n# Example: List all DevTest Labs in the subscription\nprint(\"Listing DevTest Labs:\")\nfor lab in client.labs.list_by_subscription():\n    print(f\"  Lab Name: {lab.name}, Location: {lab.location}\")\n","lang":"python","description":"This quickstart demonstrates how to instantiate the DevTestLabsClient using DefaultAzureCredential and then list all DevTest Labs available within your Azure subscription. Ensure `AZURE_SUBSCRIPTION_ID` is set in your environment variables for this to run."},"warnings":[{"fix":"Update your import statement to `from azure.mgmt.devtestlabs import DevTestLabsClient` and instantiate the client as `DevTestLabsClient(credential, subscription_id)`.","message":"The primary client class name changed from `DevTestLabsManagementClient` to `DevTestLabsClient` in the V2 SDK. Code written for older versions will need to update the import and instantiation.","severity":"breaking","affected_versions":"Prior to 9.0.0 (V2 SDK)"},{"fix":"Consult the official V2 SDK documentation and API reference for the `azure-mgmt-devtestlabs` library to understand the updated resource models and method signatures. Update your code to reflect the new structure.","message":"Resource models and API methods may have changed significantly between major versions (e.g., V1 to V2 SDK). Property names, argument order, and response structures might differ, leading to `AttributeError` or `TypeError`.","severity":"breaking","affected_versions":"Prior to 9.0.0 (V2 SDK)"},{"fix":"For synchronous code, use `DevTestLabsClient`. For asynchronous code, import and use `DevTestLabsClientAsync` and ensure your calls are awaited within an `async` function.","message":"The library provides both synchronous (`DevTestLabsClient`) and asynchronous (`DevTestLabsClientAsync`) clients. Ensure you are using the correct client type for your application's concurrency model (e.g., `async/await` for asynchronous operations).","severity":"gotcha","affected_versions":"All V2 versions (9.x.x+)"},{"fix":"Always iterate over the returned collection directly (e.g., `for lab in client.labs.list_by_subscription():`) rather than assuming it's a simple list or accessing elements by index directly, to ensure all pages are fetched.","message":"Many list operations (e.g., `client.labs.list_by_subscription()`) return an iterable object that performs pagination under the hood. Not all items might be immediately available, and the iterator must be fully consumed to retrieve all results.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}