Azure DevTest Labs Management

9.0.0 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.devtestlabs import DevTestLabsClient

# Set your Azure Subscription ID as an environment variable
# E.g., export AZURE_SUBSCRIPTION_ID="<your-subscription-id>"
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
    raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")

# Authenticate using DefaultAzureCredential
# This will try various authentication methods, like environment variables,
# managed identity, Azure CLI, VS Code, etc.
credential = DefaultAzureCredential()

# Create a DevTestLabsClient
client = DevTestLabsClient(credential, subscription_id)

# Example: List all DevTest Labs in the subscription
print("Listing DevTest Labs:")
for lab in client.labs.list_by_subscription():
    print(f"  Lab Name: {lab.name}, Location: {lab.location}")

view raw JSON →