{"id":1930,"library":"azure-mgmt-imagebuilder","title":"Microsoft Azure Image Builder Client Library for Python","description":"This is the Microsoft Azure Image Builder Client Library for Python. It provides the necessary tools to interact with the Azure VM Image Builder service to define, build, and distribute custom virtual machine images. The current version is 1.4.0, and it follows the Azure SDK release cadence, with frequent updates for features and bug fixes.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","cloud","management","image builder","vm","sdk"],"install":[{"cmd":"pip install azure-mgmt-imagebuilder azure-identity","lang":"bash","label":"Install package and authentication library"}],"dependencies":[{"reason":"Required for Azure Active Directory token authentication, typically using DefaultAzureCredential.","package":"azure-identity","optional":false}],"imports":[{"note":"The client class is directly under the top-level package for modern Azure SDKs.","wrong":"from azure.mgmt.imagebuilder.image_builder_client import ImageBuilderClient","symbol":"ImageBuilderClient","correct":"from azure.mgmt.imagebuilder import ImageBuilderClient"},{"note":"Older Azure SDK versions used `azure.common.credentials` or `msrestazure.azure_active_directory`. Modern SDKs use `azure-identity` for unified authentication.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.imagebuilder import ImageBuilderClient\n\n# Set environment variables for authentication and subscription\n# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET\n# AZURE_SUBSCRIPTION_ID\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\nresource_group_name = \"myResourceGroup\"\n\n# Authenticate and create client\ntry:\n    credential = DefaultAzureCredential()\n    client = ImageBuilderClient(credential=credential, subscription_id=subscription_id)\n    print(f\"ImageBuilderClient created for subscription: {subscription_id}\")\n\n    # Example: List all image templates in a resource group\n    print(f\"\\nListing image templates in resource group '{resource_group_name}':\")\n    templates = client.virtual_machine_image_templates.list_by_resource_group(resource_group_name=resource_group_name)\n    for template in templates:\n        print(f\"  - {template.name} ({template.id})\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    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.\")","lang":"python","description":"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."},"warnings":[{"fix":"Migrate authentication code to use `azure-identity` library classes like `DefaultAzureCredential`.","message":"The 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`).","severity":"breaking","affected_versions":"<1.0.0b1"},{"fix":"Update automation logic to parse the new error schema. Avoid reverting to older API versions after switching.","message":"API version 2021-10-01 introduced a change to the error schema for Image Builder. Automations parsing error outputs from earlier API versions may break.","severity":"breaking","affected_versions":">=1.0.0 (when using API version 2021-10-01 or later)"},{"fix":"Ensure that any specified subnets in `subnetId` or `containerInstanceSubnetId` fields have outbound access enabled if the build or validation VMs require it.","message":"After 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.","severity":"breaking","affected_versions":"All (impacts deployments after March 31, 2026)"},{"fix":"Ensure 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.","message":"Azure 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your environment uses Python 3.8 or later, as required by the package.","message":"Support for Python 2.7 by Azure SDK Python packages officially ended on January 1, 2022.","severity":"deprecated","affected_versions":"All"},{"fix":"For large file downloads, use customizer scripts with appropriate download tools instead of the direct file customizer.","message":"The '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`).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}