Skip to content

feat(azure-compute): create managed image from a disk - #908

Merged
NitinKumar004 merged 1 commit into
developmentfrom
feat/azure-image-from-disk
Aug 30, 2026
Merged

feat(azure-compute): create managed image from a disk#908
NitinKumar004 merged 1 commit into
developmentfrom
feat/azure-image-from-disk

Conversation

@NitinKumar004

Copy link
Copy Markdown
Collaborator

What

Adds a source-disk path for Azure managed images. Previously an image could only be created by capturing a VM (sourceVirtualMachine). This lets armcompute ImagesClient create a Microsoft.Compute/images directly from an existing managed disk via storageProfile.osDisk.managedDisk.id, with no VM involved.

  • driver.ImageConfig / ImageInfo gain optional OSDiskID / OSType / OSState / DiskSizeGB — a disk-source alternative to InstanceID.
  • The images handler branches: when sourceVirtualMachine is absent but storageProfile.osDisk.managedDisk.id is present, it resolves the disk by its ARM name (mirroring disks/handler.go), captures its size, and creates the image from the disk. The VM-capture branch is untouched.
  • Response echoes the storageProfile.osDisk with managedDisk, osType, osState, diskSizeGB. Sync-200 (no LRO), matching the existing images poller contract.

Architecture fit

  • Additive-only: a VM-captured image is byte-unchanged when the new fields are absent — the new response fields (managedDisk, and the new ImageInfo json tags) are all omitempty, so old images serialize identically on the wire and in snapshots.
  • ID-space discipline: OSDiskID holds the client-facing ARM disk ID (drift-safe echo); the wire handler owns disk-existence validation (the provider does not treat it as a driver key).
  • The hugeParam gocritic nolint added to each CreateImage impl (AWS/GCP/Azure/portable) follows the existing interface-signature convention (UpdateVolume already carries it) — growing ImageConfig past 80 bytes trips it uniformly.

Persistence note

The images store is already in the VM mock's snapshot dumps list, and the new ImageInfo fields are exported, so they persist automatically. Verified with a snapshot -> restore round-trip test asserting OSDiskID/OSType/OSState/DiskSizeGB survive.

Test

  • Real-SDK e2e (armcompute DisksClient + ImagesClient): create a disk, create an image from managedDisk.id (no sourceVirtualMachine) -> Get round-trips osType/osState/diskSizeGB/managedDisk.id, and sourceVirtualMachine is absent.
  • Negative e2e: image-from-a-missing-disk fails rather than producing an empty image.
  • Provider unit tests (from-disk, no-source error) + the snapshot round-trip test.
  • Existing VM-capture SDK/wire tests still pass unchanged.

Ref #611.

Extend driver ImageConfig/ImageInfo with a disk-source alternative
(OSDiskID/OSType/OSState/DiskSizeGB). The Azure images handler now
builds a managed image directly from storageProfile.osDisk.managedDisk.id
when sourceVirtualMachine is absent, validating the disk and capturing
its size; the VM-capture branch is unchanged. Ref #611.
@NitinKumar004
NitinKumar004 merged commit b2aec59 into development Aug 30, 2026
18 checks passed
@NitinKumar004
NitinKumar004 deleted the feat/azure-image-from-disk branch August 30, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant