Registry /
azure / azure-mgmt-imagebuilder
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.636s · 43.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.8s · import 0.532s · 44MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ImageBuilderClient
✓ from azure.mgmt.imagebuilder import ImageBuilderClient
✗ from azure.mgmt.imagebuilder.image_builder_client import ImageBuilderClient
The client class is directly under the top-level package for modern Azure SDKs.
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
✗ from azure.common.credentials import ServicePrincipalCredentials
Older Azure SDK versions used `azure.common.credentials` or `msrestazure.azure_active_directory`. Modern SDKs use `azure-identity` for unified authentication.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and create an `ImageBuilderClient`. It then shows how to list virtual machine image templates within a specified resource group. Ensure `AZURE_SUBSCRIPTION_ID`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` environment variables are set for successful authentication.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.imagebuilder import ImageBuilderClient
# Set environment variables for authentication and subscription
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
# AZURE_SUBSCRIPTION_ID
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID")
resource_group_name = "myResourceGroup"
# Authenticate and create client
try:
credential = DefaultAzureCredential()
client = ImageBuilderClient(credential=credential, subscription_id=subscription_id)
print(f"ImageBuilderClient created for subscription: {subscription_id}")
# Example: List all image templates in a resource group
print(f"\nListing image templates in resource group '{resource_group_name}':")
templates = client.virtual_machine_image_templates.list_by_resource_group(resource_group_name=resource_group_name)
for template in templates:
print(f" - {template.name} ({template.id})")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID) are set correctly and the resource group exists.")
Debug
Known issues
breakingThe credential system was revamped in the 1.x.x series (e.g., 1.0.0b1). `azure.common.credentials` and `msrestazure.azure_active_directory` are no longer supported. Use classes from `azure-identity` (e.g., `DefaultAzureCredential`).fixMigrate authentication code to use `azure-identity` library classes like `DefaultAzureCredential`.
affects: <1.0.0b1
breakingAPI version 2021-10-01 introduced a change to the error schema for Image Builder. Automations parsing error outputs from earlier API versions may break.fixUpdate automation logic to parse the new error schema. Avoid reverting to older API versions after switching.
affects: >=1.0.0 (when using API version 2021-10-01 or later)
breakingAfter March 31, 2026, new virtual networks in Azure will default to private subnets. This affects AIB templates that specify `subnetId` or `containerInstanceSubnetId`, requiring explicit outbound access for build/validation VMs if needed.fixEnsure that any specified subnets in `subnetId` or `containerInstanceSubnetId` fields have outbound access enabled if the build or validation VMs require it.
affects: All (impacts deployments after March 31, 2026)
gotchaAzure VM Image Builder requires a user-assigned managed identity with specific permissions (e.g., 'Managed Identity Operator' role, read/write to images, read from storage for scripts) to function correctly. Lack of permissions is a common cause of failures.fixEnsure a user-assigned managed identity is created and assigned the necessary roles to the Image Builder resource, source image resource group, distribution targets, and any storage accounts holding customizer scripts.
affects: All
deprecatedSupport for Python 2.7 by Azure SDK Python packages officially ended on January 1, 2022.fixEnsure your environment uses Python 3.8 or later, as required by the package.
affects: All
gotchaThe 'file' customizer in Azure Image Builder is only suitable for small file downloads (< 20MB). For larger files, it's recommended to use a script or inline command to download them (e.g., `wget`, `curl`, `Invoke-WebRequest`).fixFor large file downloads, use customizer scripts with appropriate download tools instead of the direct file customizer.
affects: All
Upgrade
Version history
2.0.0latest on PyPI · released Jun 2, 2026
Audit
Dependencies
azure-identityrequiredRequired for Azure Active Directory token authentication, typically using DefaultAzureCredential.