Troubleshooting, Image capturing of VM
I am trying to capture image of a vm and save it into gallery and getting this error any assistance please??
Azure Virtual Machines
-
Nikhil Duserla • 6,470 Reputation points • Microsoft External Staff
2025-04-08T14:40:48.4866667+00:00 I would recommend follow this link to Capture a VM in the portal-https://learn.microsoft.com/en-us/azure/virtual-machines/capture-image-portal#capture-a-vm-in-the-portal
Note- Once you mark a VM as
generalized
in Azure, you cannot restart the VM. Capturing a virtual machine image will make the virtual machine unusable. This action cannot be undone.If you have any further queries, do let us know.
-
Varshney, Aayushi • 0 Reputation points
2025-04-08T14:53:27.5233333+00:00 @Nikhil Duserla Thanks for helping, but i need to do this via git pipeline, This part of migration of azure for our organization. so can not be done manually from portal.
-
Nikhil Duserla • 6,470 Reputation points • Microsoft External Staff
2025-04-10T14:54:53.9766667+00:00 Just checking to see if you've resolved the issue. I recommend following this link to capture an image using the Azure CLI: https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images#create-a-gallery
-
Nikhil Duserla • 6,470 Reputation points • Microsoft External Staff
2025-04-14T10:51:29.69+00:00 Checking to see whether you have resolved the issue with the solution provided above, or if you need any further assistance, please let us know. We are happy to help.
-
Varshney, Aayushi • 0 Reputation points
2025-04-15T05:12:04.61+00:00 so sorry to say, but unfortunately your second approach also giving errors and not allowing me to upload image to gallery.
-
Venkat V • 1,390 Reputation points • Microsoft External Staff
2025-04-15T12:30:39.5266667+00:00 az sig image-definition create
, but encountering a 400 Bad Request error. This typically indicates missing or incorrect parameters in the command. For more detailed information and examples, refer to the official Azure CLI documentation:Reference: az sig image-definition create
-
Arko • 1,550 Reputation points • Microsoft External Staff
2025-04-16T14:05:18.1633333+00:00 Which region are you trying to use this in? and is it a gen1 ubuntu (which version) vm or windows VM (which version)?
-
Arko • 1,550 Reputation points • Microsoft External Staff
2025-04-16T15:07:38.14+00:00 Hello Varshney, Aayushi, the 400 Bad Request error typically indicates that some parameter passed to the
az sig image-version create
command is either invalid, malformed, or missing. In your case, based on the verbose part of the URL,--sku ""v1.0""
is invalid — double quotes inside double quotes.It should be --sku v1 or any non-empty string without special quotes. Also managed image
$IMAGE_NAME
is not found or incorrectly referenced. You need to reference either a managed image resource ID or an existing VM name (if using--source
)or you might have incorrect
--hyper-v-generation
vs source image compatibility i.e. if you have set--hyper-v-generation V2
but your source image is V1 or doesn’t support secure boot.Please reference from the below steps and let me know
az vm create \ --resource-group arkorg \ --name mySourceVM \ --image Canonical:UbuntuServer:18_04-lts-gen1:latest \ --size Standard_D2s_v3 \ --admin-username azureuser \ --generate-ssh-keys \ --security-type Standard \ --enable-secure-boot false \ --enable-vtpm false
Note- Only Gen1 images work here. Gen2 images often cause
SecureBootClientError
if they are unsigned. You can list Gen1 images using-az vm image list \ --publisher Canonical \ --offer UbuntuServer \ --sku 18_04-lts \ --all \ --location westeurope \ --output table
Generalize the VM
az vm deallocate --resource-group arkorg --name whatever_is_ur_vm_name az vm generalize --resource-group arkorg --name whatever_is_ur_vm_name
Create a shared image gallery & definition
az sig create \ --resource-group arkorg \ --gallery-name myGallery az sig image-definition create \ --resource-group arkorg \ --gallery-name myGallery \ --gallery-image-definition myImageDef \ --publisher myPublisher \ --offer UbuntuServer \ --sku v1 \ --os-type Linux \ --os-state Generalized \ --hyper-v-generation V1
Please note- default is Gen2 with TrustedLaunch. Use
--hyper-v-generation V1
explicitly and omit security flags if usingaz sig image-definition
.Create an image version from the generalized VM
az sig image-version create \ --resource-group arkorg \ --gallery-name myGallery \ --gallery-image-definition myImageDef \ --gallery-image-version 1.0.0 \ --managed-image /subscriptions/<SUB_ID>/resourceGroups/arkorg/providers/Microsoft.Compute/images/myManagedImage
Alternatively, if you're using a VM directly the run this-
az sig image-version create \ --resource-group arkorg \ --gallery-name myGallery \ --gallery-image-definition myImageDef \ --gallery-image-version 1.0.0 \ --source mySourceVM
Reference MS documents-
-
Arko • 1,550 Reputation points • Microsoft External Staff
2025-04-17T08:51:48.92+00:00 Following up. Hope I was able to guide you here Varshney, Aayushi.
-
Arko • 1,550 Reputation points • Microsoft External Staff
2025-04-18T13:51:02.89+00:00 Hello Aayushi, Hope your query is resolved now.
Sign in to comment