canonical: https://jentic.com/apis/azure.com/virtualmachineimagetemplate

# Microsoft Azure VirtualMachineImageTemplate

Jentic publishes the only available OpenAPI specification for VirtualMachineImageTemplate, keeping it validated and agent-ready. The Azure VM Image Builder API (Microsoft.VirtualMachineImages) lets agents define imageTemplate resources that describe a source image, a list of customizers (shell, PowerShell, Windows-update, file copy), and one or more distribute targets (Managed Image, Shared Image Gallery, VHD). Once the template is created, agents trigger a build via the run action, list runOutputs to inspect generated artefacts, and use the resulting images to provision standardised VM fleets. Authentication uses Azure Active Directory OAuth 2.0.

## For AI agents

Defines and runs Azure VM Image Builder templates so agents can produce custom Managed Images, Shared Image Gallery versions, or VHDs from a scripted build pipeline.

## Scope

Does not provision VMs, manage disks, or configure networking - use the Compute, Disk, and Network management APIs for those; this API only defines and runs imageTemplate resources.

## Capabilities

- Create an imageTemplate that customises a source Marketplace, Managed, or Platform image with shell, PowerShell, or Windows-update steps
- Distribute a built image to a Managed Image, Shared Image Gallery version, or VHD blob target in a single template
- Trigger a build of a defined imageTemplate via the run action and produce a versioned artefact in the configured distribute targets
- List runOutputs of a template to retrieve the resource IDs and locations of every distributed artefact for downstream provisioning
- List imageTemplates by subscription or resource group to inventory active and successful image pipelines
- Update the customizer or distribute lists on an existing imageTemplate to evolve the build without recreating it
- Delete an imageTemplate when its image lineage is retired so the resource group stays tidy

## Use cases

### Golden image pipeline for a VM fleet

Platform teams maintaining a standardised VM fleet need a reproducible golden image that includes patched OS, agents, and baseline configuration. The agent creates an imageTemplate that pulls an Ubuntu 20.04 LTS source, runs a shell customizer to install the monitoring agent and harden SSH, and distributes the result to a Shared Image Gallery version. Triggering the run action builds the image; subsequent VM Scale Sets use the gallery version directly.

Example prompt: Create imageTemplate 'web-baseline' in resource group 'images-rg' with source=PlatformImage Canonical UbuntuServer 20_04-lts latest, a shell customizer running 'apt-get update && apt-get install -y nginx', and distribute=SharedImage to gallery '/subscriptions/.../galleries/myGallery/images/web' version 1.0.0; then POST the run action.

### Windows patched image refresh

A Windows VM fleet needs monthly patched images. The agent updates an existing imageTemplate to use the latest Windows Server source, ensures a windows-update customizer is present, and triggers a new run. The runOutputs endpoint returns the new gallery image version, which downstream Scale Set updates can consume to roll out patches without provisioning ad hoc VMs first.

Example prompt: Update imageTemplate 'win-baseline' to a newer source image, POST run, then poll GET /runOutputs until lastRunStatus.runState=Succeeded and return the distributed image versionId.

### Per-region distribute fan-out

Multi-region deployments need an image present in each region's Shared Image Gallery. Agents define a single imageTemplate whose distribute array contains one SharedImage entry per target gallery and region. A single run produces image versions in every region in parallel, replacing fragile per-region scripts and keeping image lineage consistent.

Example prompt: Create imageTemplate 'multi-region-web' with three distribute SharedImage entries pointing at galleries in westeurope, eastus, and southeastasia; trigger run; list runOutputs and return the three resulting image version IDs.

### Agent-driven image build via Jentic

An ops agent fielding 'rebuild the golden image with the latest CVE patch' can chain image-template update, run, and runOutputs queries through Jentic. Jentic exposes each operation with its input schema and handles the AAD bearer token from the vault, so the agent only needs to compose the customizer and distribute payload and watch for completion.

Example prompt: Search Jentic for 'run azure vm image template', execute POST run on imageTemplate 'web-baseline' in 'images-rg', then poll GET runOutputs until Succeeded and return the new image version.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /subscriptions/{subscriptionId}/providers/Microsoft.VirtualMachineImages/imageTemplates | List image templates in the subscription |
| PUT | /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName} | Create or update an image template |
| POST | /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run | Trigger a build of the image template |
| GET | /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/runOutputs | List the artefacts produced by the latest run |
| DELETE | /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName} | Delete an image template |

## Key resources

- **imageTemplates** — List/create/update/delete imageTemplate resources by subscription and resource group
- **imageTemplates/run** — Action endpoint that triggers a build of the configured customizers and distribute targets
- **imageTemplates/runOutputs** — Read-only list and get of artefacts produced by the most recent build
- **operations** — Lists the operations the Microsoft.VirtualMachineImages provider exposes

## Why Jentic

- **Setup:** Wiring VirtualMachineImageTemplate by hand means configuring Azure AD OAuth 2.0 against management.azure.com, pinning the 2019-05-01-preview api-version, learning the imageTemplate source, customize, and distribute schema, and polling the long-running run action with ARM 429 back-off yourself. Through Jentic you install once, import VirtualMachineImageTemplate from the API Directory, store the Azure AD OAuth token once, and your agent calls it.
- **Permission scoping:** Subscription, resource group, and template name are URL path parameters (/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}), so a rule can pin your agent to templates in one resource group. You choose the operations it may call, so destructive ones like deleting a template or overwriting one with PUT are not included unless you add them.
- **Credential handling:** Your Azure AD OAuth token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'create an Azure VM image template' or 'run an image build and read its outputs', and Jentic returns the matching Microsoft.VirtualMachineImages operation with the imageTemplate schema for source, customize, and distribute so the agent fills it without reading the ARM reference.

## Related APIs

- **ComputeManagementClient** — Provisions VMs and Scale Sets from the images produced by VirtualMachineImageTemplate
- **ComputeDiskAdminManagementClient** — Manages the underlying disks behind images and VMs
- **ComputeManagementConvenienceClient** — Higher-level compute management surface than the raw ARM compute client

## FAQ

### Why is there no official OpenAPI spec for VirtualMachineImageTemplate?

Microsoft Azure does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call VirtualMachineImageTemplate via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer .

### What authentication does the VirtualMachineImageTemplate API use?

Azure Active Directory OAuth 2.0 with the user_impersonation scope against https://login.microsoftonline.com/common/oauth2/authorize. Through Jentic the AAD client secret stays encrypted in the vault and the agent only ever sees a scoped bearer token at execution time.

### Can I trigger an image build with the VirtualMachineImageTemplate API?

Yes. POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{name}/run starts a build. The operation is long-running; poll the imageTemplate's lastRunStatus.runState or the operation status URL until it reaches Succeeded or Failed.

### What are the rate limits for the VirtualMachineImageTemplate API?

Calls go through Azure Resource Manager, subject to the standard ARM read and write throttling envelope. Image build durations themselves depend on customizers and source image; they are not rate-limited but are bounded by the buildTimeoutInMinutes you configure on the template.

### How do I distribute a built image to a Shared Image Gallery through Jentic?

Run pip install jentic, then client.search('create azure vm image template'), client.load on the returned PUT, and client.execute with distribute containing a SharedImage entry pointing at the gallery image resource ID and version. Then call client.search('run azure vm image template') and execute the POST run action.

### Can I use a custom Managed Image as the source for an imageTemplate?

Yes. Set source.type=ManagedImage and source.imageId to the resource ID of the existing Managed Image. PlatformImage and SharedImageVersion are also valid source types in the spec.

### Can I limit what my agent is allowed to do with the VirtualMachineImageTemplate API?

Yes. Jentic One is self-hosted, so your own rules decide which VirtualMachineImageTemplate operations and credentials the agent can use. Because subscription, resource group, and template name are URL path parameters, you can pin the agent to imageTemplates in a single resource group, and you choose which operations it may call, so destructive ones like deleting a template or overwriting one with PUT stay out of reach unless you add them. You can, for example, grant only the run action and the runOutputs read while withholding create, update, and delete.
