Azure Python DevTools

raw JSON →
1.2.0 verified Fri May 01 auth: no python maintenance

Microsoft Azure Development Tools for SDK – provides utilities for CI (Git helpers, GitHub REST API wrapper, issue bot framework), scenario testing (resource management, playback support), and config management. Current version: 1.2.0. Released September 2020, low maintenance cadence.

pip install azure-devtools
error ImportError: No module named 'azure_devtools'
cause Package name with hyphen vs underscore: pip installs 'azure-devtools', but imports are underscore 'azure_devtools'.
fix
Run: pip install azure-devtools
error AttributeError: module 'azure_devtools' has no attribute 'scenario_tests'
cause The scenario_tests subpackage is not automatically imported; you must import it explicitly.
fix
Use: from azure_devtools.scenario_tests import ...
error TypeError: create_random_name() got an unexpected keyword argument 'length'
cause Function signature changed between versions; older versions accepted 'length', newer ones do not.
fix
Use create_random_name(prefix='test', length=20) – check documentation for your version. For >=1.2.0, only 'prefix' is accepted.
gotcha ResourceGroupPreparer only works with positional arguments. If you change the function signature and the resource_group parameter is not the first argument, the preparer will fail silently.
fix Ensure resource_group is the first parameter of your test function after self if using pytest or unittest method.
deprecated The ci_tools module (Git helpers, GitHub REST API wrapper) is no longer actively maintained and may be removed in future versions. Prefer dedicated GitHub Actions or Azure DevOps tasks.
fix Migrate to GitHub CLI (`gh`) or Azure DevOps REST API directly.
breaking In version 1.0.0, the resource removal sequence was reversed. Tests that relied on a specific deletion order may fail or leave resources behind.
fix Check your resource cleanup logic; use ResourceGroupPreparer with 'random_name' setting to avoid dependency on deletion order.

Example of using ResourceGroupPreparer in a test to create and clean up a resource group.

from azure_devtools.scenario_tests.preparers import ResourceGroupPreparer
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import DefaultAzureCredential
import os

credential = DefaultAzureCredential()
subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', '')

@ResourceGroupPreparer()
def test_resource_group(resource_group, **kwargs):
    client = ResourceManagementClient(credential, subscription_id)
    rg = client.resource_groups.get(resource_group.name)
    print(f"Resource group {rg.name} exists in {rg.location}")