Import machine images Stay organized with collections Save and categorize content based on your preferences.
A machine image lets you store the configuration, metadata, permissions, anddata from one or more disks for a virtual machine (VM) instance running onCompute Engine. For information about when and how to use machine images,seeMachine images.
This page describes the steps that you can use to import a machine image from avirtual appliance usingMigrate to Virtual Machines.
Before you begin
- Enable the VM Migration APIon your project.
- Verify that the boot disk is configured with asupported operating system.
Supported file formats
You can import machine image files in the following formats usingMigrate to Virtual Machines:
Open Virtualization Format (OVF): One OVF file and virtual machine disk(VMDK) files in the same bucket.
Note: Migrate to Virtual Machines only supports importing VMDK disk files in theOVF format. To import any other type of disk file, you must first convert thedisk file to an OVA file and then import it.Open Virtual Appliance (OVA): One OVA file containing an OVF file and diskfiles. Migrate to Virtual Machines supports importing OVA machine image files inthe following disk file formats:
- Virtual machine disk (VMDK)
- QEMU copy-on-write (QCOW)
- QEMU copy-on-write 2 (QCOW2)
- QEMU enhanced disk format (QED)
- VPC
- Virtual disk image (VDI)
- Virtual hard disk v2 (VHDX)
Limitations
When you import machine images, the following limitations apply:
- You can only import machine images toregions that support N2 instance families.
- You can't import machine images to4th generation machine series.For more information, seemachine image import limitations and restrictions
- You can't import Arm architecture-based machine images.
- You can't create machine images from source VMs with any of the following:
- Attached disks greater than 200 TB
- A4, A3, C3D, H3, or Z3 machine types
Machine image import process
To import a machine image to Compute Engine machine image usingMigrate to Virtual Machines, use the following steps:
- Prepare a machine image file for import
- Choose a target project
- Import a machine image to Compute Engine
Prepare a machine file for import
To import a machine image to a Compute Engine image, you must firstprepare the machine image file for import. The following sections discussthese tasks in detail.
Add the machine image file to Cloud Storage
To import a machine image to a Compute Engine machine image, you must firstadd the machine image file to Cloud Storage. For more information, seeUpload objects from a file system. Forbetter performance, we recommend that you upload the machine image file toa bucket in the same Google Cloud in which you want to create the machineimage.
Grant the required permissions
To import a machine image to a Compute Engine machine image, grant permissionsas described in the following table.
| Role | Permissions required | Description |
|---|---|---|
| Storage Object Viewer | roles/storage.objectViewer | Grant the default Migrate to Virtual Machines service account in the host project (service-HOST_PROJECT_NUMBER@gcp-sa-vmmigration.iam.gserviceaccount.com) theroles/storage.objectViewer role on the bucket where the image you want to import resides. This permission lets Migrate to Virtual Machines access the source image. |
| VM Migration Administrator | roles/vmmigration.admin | In the host project, grant the user account that you want to use to import the source image theroles/vmmigration.admin role. |
| VM Migration Service Account | roles/vmmigration.serviceAgent | Grant the default Migrate to Virtual Machines service account in the host project (service-HOST_PROJECT_NUMBER@gcp-sa-vmmigration.iam.gserviceaccount.com) theroles/vmmigration.serviceAgent role on the target project. For example, ifservice-1234567890@gcp-sa-vmmigration.iam.gserviceaccount.com is the Migrate to Virtual Machines service account in the host project, you must grant this service account theroles/vmmigration.serviceAgent role to be able to create the image in the target project. |
Choose a target project
To host the machine image, you must create or choose a target project. A targetproject defines the destination project for a machine image.For more information on creating or choosing a target project, seeAdding a target project.
Import a machine image to Compute Engine
You can import a machine image to Compute Engine using the Google Cloud console,Google Cloud CLI, or REST API commands.
When you import a machine image, Migrate to Virtual Machines creates some temporaryresources, such as VMs or disks, in the target project. These temporaryresources are deleted when the machine image import process is complete.
Console
To import a machine image to Compute Engine using the Google Cloud console, usethe following steps.
Open the Migrate to Virtual Machines page in the Google Cloud console.
Select theMachine Image Imports tab.
ClickCreate a machine image.
Define the characteristics of the image. The following table lists theparameters that you can set for your machine image.
Section title Field name Description General Name The name of the machine image that you want to create. For moreinformation on the naming rules, seeNaming convention. Machine image import ID An ID that represents the machine image import resource. When youimport a machine image to Compute Engine, Migrate to Virtual Machines firstcreates a machine image import resource. The machine image importresource represents the machine image import job. You can use theMachine Image import ID to get the link to the machine image that wasimported as part of the machine image import process. Source file input The file from which you want to import the machine image. ClickBrowse to view the list of buckets in your currentproject, and select the file from which you want to import the machineimage.
If you want to import a machine image from a bucket from another project,you must enter the path in the formatbucket/folder/file. To getthe path of an object inside a bucket, seeView object metadata. When you copy the path, make sure that you don't copythegs://prefix.
Note that you can only import machine images from.ovaand.ovffiles.Region The region in which you want to create the machine image. For a listof supported regions, seeRegions and zones. Target project The target project in which you want to create the machine image. Ifyou've not already added a target project, do so using the instructionsgiven inAdd a target project. Auto-select Compute Engine machine type Automatically selects the machine type from the source file. Thisoption is enabled by default. If you want to manually select the machinetype series and machine type, click this field to the off position. Machine type series Select the machine type series for the machine image. This field isvisible only when theAuto-select GCE machine type option is disabled.Note that the machine type series available for selection is dependent onthe region you've selected. For more information, seePredefined machine types. Machine type Select the machine type. Description (Optional) Add a description for the machine image. Skip OS adaptation To skip OS adaptation, click theSkip OS adaptationtoggle to the on position.
To function properly on Google Cloud, VMs created from imported machineimages require changes to be made to their configuration. These changesare referred to asOS adaptations. Migrate to Virtual Machines performsOS adaptations automatically in the machine image import process. For moreinformation, seeAdapt VM instances to run on Google Cloud.Generalize To generalize the machine image, click theGeneralizetoggle to the on position. When you create an instance from a machineimage, Windows adds some unique information to the instance. Generalize isa process that removes this information so that you can create multipleinstances from the same machine image. Licenses License type Compute Engine supports pay as you go (PAYG) licenses and bring yourown licenses (BYOL) for your deployed VMs. The default license type for amigrated VM is assigned by Migrate to Virtual Machines based on the migratedoperating system, as described inSupported operating systems.
If your operating system supports multiple license types, you can overridethe default license type to explicitly specify a license type of PAYG orBYOL.
Note: Some operating system types,such as CentOS and Debian, don't support a license. Other operatingsystems only support one type of license. Attempting to set an unsupportedlicense type causes an error when you attempt to import the machine image.Additional licenses Additional licenses You can add up to 10 additional licenses to the VM instance createdfrom the imported machine image using a valid URL format. For example, youcan add additional licenses using the following URL format: https://www.googleapis.com/compute/beta/projects/windows-sql-cloud/global/licenses/sql-server-2012-enterprise
Labels To organize your project, add labels as key-value pairs to yourresources. SeeOrganize resources using labels. Encryption Google-managed encryption key Choose this option to use Google-owned and Google-managed encryption key to encryptyour data during the import process. For more information, seeencrypts data when it is at rest. Customer managed encryption key Choose this option to use customer-managed encryption keys (CMEK) toencrypt your data during the import process, and the data of the imagecreated by the import process. If you have specific compliance orregulatory requirements related to the keys that protect your data, youcan useCMEK to encrypt and decrypt your data.These encryption keys are created, managed, and owned by you. For moreinformation, seeProtect resources by using Cloud KMS keys.
When you add a CMEK, you must grant permissions as described in thefollowing table.Role Permissions required Description Cloud VM Migration Service Account roles/vmmigration.serviceAgentGrant this permission to the Compute Engine service account to encrypt data of the machine image created during the import process. Compute Engine Service Agent roles/compute.serviceAgentGrant this permission to the Migrate to Virtual Machines service agent to encrypt the data during the import process. SelectCreate.
gcloud
To import a machine image to Compute Engine using the Google Cloud CLI,use the following request.
gcloud compute migration machine-image-imports createIMAGE_NAME \--source-file=SOURCE_FILE \--location=REGION_ID \--target-project=projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT
Replace the following:
IMAGE_NAME: the name of the machine image that youwant to create. For more information on the naming rules, seeNaming convention.SOURCE_FILE: the file from which you want toimport the machine image. Enter the path in the formatgs://bucket/folder/file.To get the path of an object inside a bucket, seeView object metadata.Note that you can only import images from.ovfand.ovafiles.REGION_ID: the region in which you want the machineimage import process to run. The machine image is created in the closestmulti-region. If you want the machine image to be created in a region,verify thatsingleRegionStorageis set to true. For a list ofsupported regions, seeRegions and Zones.HOST_PROJECT_ID: the name of the host projectfrom which you want to migrate the machine image.TARGET_PROJECT: the target project in which youwant to create the machine image. If you've not already added a targetproject, do so using the instructions given inAdd a target project.
For more information, seegcloud migration vms machine-image-imports
REST API
To import a machine image to Compute Engine using the REST API, use thefollowing steps.
Create a machine image import resource using the following request.
POST https://vmmigration.googleapis.com/v1/projects/HOST_PROJECT_ID/locations/REGION_ID/imageImports?imageImportId=IMPORT_NAME{"cloudStorageUri": "SOURCE_FILE","machineImageTargetDefaults": {"imageName": "IMAGE_NAME","targetProject": "projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT",...}}Replace the following:
HOST_PROJECT_ID: the name of the host projectfrom which you want to migrate the machine image.REGION_ID: the region in which you want themachine image import process to run. The machine image is created in theclosest multi-region. If you want the machine image to be created in aregion, verify thatsingleRegionStorageis set to true. Fora list of supported regions, seeRegions and Zones.SOURCE_FILE: the file from which you want toimport the machine image. Enter the path in the formatgs://bucket/folder/file.To get the path of an object inside a bucket, seeView object metadata.Note that you can only import machine images from.ovaand.ovffiles.IMAGE_NAME: the name of the machine image thatyou want to create. For more information on the naming rules, seeNaming convention.TARGET_PROJECT: the target project in which youwant to create the machine image. If you've not already added a targetproject, do so using the instructions given inAdd a target project.
In this example,
IMPORT_NAMEis an ID thatrepresents the machine image import resource. When you import an machineimage to Compute Engine, Migrate to Virtual Machines creates an first createsan machine image import resource. The machine image import resourcerepresents the machine image import process. You can use theIMPORT_NAMEto get the link to the machine imagethat was imported as part of the machine image import process.See the following table for the full list of machine image import createrequest fields supported fields.
Field name Description cloudStorageUriThe path of the file from which you want to import the machine image.Enter the path in the formatgs://bucket/folder/file. To get thepath of an object inside a bucket, seeView object metadata.
Note that you can only import machine images from.ovfand.ovafiles.machineImageTargetDefaults.targetProjectThe target project in which you want to create the machine image. For moreinformation, seetarget project API reference.For example, projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT
In the example, replace the following:HOST_PROJECT_ID: the name of the host projectfrom which you want to migrate the machine image.TARGET_PROJECT: the target project in whichyou want to create the image.
machineImageTargetDefaults.machine_image_nameThe name of the machine image to be created.For more information on the naming rules, seeresource naming convention. machineImageTargetDefaults.description(Optional) A description of the machine image. machineImageTargetDefaults.machine_type(Optional) The machine to create the machine image with. If you don'tspecify the machine type, Migrate to Virtual Machines chooses a relevantmachine type based on the information from the source machine image. machineImageTargetDefaults.labelsTo organize your project, add labels as key-value pairs to yourresources. SeeLabeling resources. machineImageTargetDefaults.tagsAdd any tags that you want to attach to the machine image. SeeManage tags for resources. machineImageTargetDefaults.additionalLicensesYou can add up to 10 additional licenses to the VM instance createdfrom the imported machine image using a valid URL format. For example, youcan add additional licenses using the following URL format: https://www.googleapis.com/compute/beta/projects/windows-sql-cloud/global/licenses/sql-server-2012-enterprise
machineImageTargetDefaults.service_accountSpecify the service account on the target project used by the machineimage. By default, no service account is assigned to the machine image.
If you create a Compute Engine instance from a machine image and plan torun an application on it, the instance might need access to othergcloud CLI services and APIs.Create a service accountin the target project with the necessary permissions to access theseservices and APIs before creating the Compute Engine instance. Then,specify that service account here. For more information, seeset up a VM to run asa service account.
To attach the service account to the Compute Engine instance, your useraccount on the Migrate to Virtual Machines host project requires the necessarypermissions. For more information, seeConfiguring permissions on target projectservice account.machineImageTargetDefaults.shielded_instance_config(Optional) Enable Shielded VM on this instance. Shielded VMsare hardened by a set of security controls that help defend againstrootkits and bootkits. SeeWhat is Shielded VM? machineImageTargetDefaults.singleRegionStorageSet this flag to true if you want the machine image storageLocationsto be a region. If you set this flag tofalse, the closest multi-region is selected.machineImageTargetDefaults.skip_os_adaptationSet this flag to true if you want to skip OS adaptation.
To function properly on Google Cloud, VMs created from imported machineimages require changes to be made to their configuration. These changesare referred to asOS adaptations. Migrate to Virtual Machines performsOS adaptations automatically in the machine image import process. For moreinformation, seeAdapt VM instances to run on Google Cloud.machineImageTargetDefaults.osAdaptationParameters.licenseTypeThe license type you want to use for your machine image. Compute Enginesupports pay as you go (PAYG) licenses and bring your own licenses (BYOL)for your deployed VMs. The default license type for a migrated VM isassigned by Migrate to Virtual Machines based on the migrated operating system,as described inSupported operating systems.
If your operating system supports multiple license types, you can overridethe default license type to explicitly specify a license type of PAYG or BYOL.
Note: Some operating system types, suchas CentOS and Debian, don't support a license. Other operating systems onlysupport one type of license. Attempting to set an unsupported license typecauses an error when you attempt to import the machine image.machineImageTargetDefaults.osAdaptationParameters.network_interfacesMigrate to Virtual Machines lets you optionally create a machine imageswith multiple network interfaces (NICs). Each interface is attached to adifferent VPC network, giving that machine image access to different VPCnetworks in gcloud CLI.
Before you add additional network interfaces, be aware of the followingconsiderations:- Attaching multiple network interfaces to the same VPC network is notsupported. While the configuration might get save, the instantiation ofthe VM will fail.
- After a Compute Engine instance is instantiated from a machineimage, you cannot add or remove a network interface on the createdinstance.
To add or remove a network interface: - SelectAdd network interface to add an additionalnetwork interface to the Compute Engine instance. You can set all of thesame options as you do with the initial network interface.
machineImageTargetDefaults.osAdaptationParameters.generalizeSet this flag to true if you want to generalize the machine image.
When you create an instance from an machine image, Windows adds someunique information to the instance. Generalization is a process thatremoves this information so that you can create multiple instances fromthe same machine image.machineImageTargetDefaults.encryptionThe Google-owned and Google-managed encryption key that you want to use to encrypt yourdata during the import process. For more information, seeDefault encryption at rest.
Usecustomer-managed encryption keys (CMEK)to encrypt the data of the machine image. These encryption keys arecreated, managed, and owned by you. For more information, seeProtect resources by using Cloud KMS keys.
Note: The encryption key that you select for use duringthe import process will also be used for the output image.
When you add a CMEK, you must grant permissions as described in thefollowing table.Role Permissions required Description Cloud VM Migration Service Account roles/vmmigration.serviceAgent Grant this permission to the Compute Engine service account to encrypt data of the machine image created during the import process. Compute Engine Service Agent roles/compute.serviceAgent Grant this permission to the Migrate to Virtual Machines service agent to encrypt the data during the import process. You should see a response similar to the following sample response.
{ "name": "projects/HOST_PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID", "metadata": { "createTime": "2023-10-31T09:12:26.94928636Z", "target": "projects/HOST_PROJECT_ID/locations/us-central1/imageImports/IMPORT_NAME", "verb": "create", "apiVersion": "v1", "@type": "type.googleapis.com/google.cloud.vmmigration.v1.OperationMetadata" }}Check if the machine image import job is complete by polling the operationusing the following command.
GET https://vmmigration.googleapis.com/v1/projects/HOST_PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID
Replace the following:
HOST_PROJECT_ID: the name of the host projectfrom which you are migrating the machine image.REGION_ID: the region in which you want themachine image import process to run. The machine image is created in theclosest multi-region. If you want the machine image to be created in aregion, verify thatsingleRegionStorageis set to true. Fora list of supported regions, seeRegions and Zones.OPERATION_ID: the operation ID of the migrate job.
You should see an operation completion response similar to the followingsample response.
{ "done": true, "name": "projects/HOST_PROJECT_ID/locations/REGION_ID/operations/OPERATION_ID", "response": { "@type": "type.googleapis.com/google.cloud.vmmigration.v1.ImageImport", "name": "projects/HOST_PROJECT_ID/locations/us-central1/imageImports/IMPORT_NAME", "cloudStorageUri": "SOURCE_FILE", "createTime": "2023-10-31T09:04:04.413664947Z", "machineImageTargetDefaults": { "imageName": "IMAGE_NAME", "targetProject": "projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT" }, "recentImageImportJobs": [ { "name": "projects/HOST_PROJECT_ID/locations/us-central1/imageImports/IMPORT_NAME/imageImportJobs/image-import-job", "diskImageTargetDetails": { "imageName": "IMAGE_NAME", "targetProject": "projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT" }, "state": "PENDING" } ] }, "metadata": { "createTime": "2023-10-31T09:04:04.416740716Z", "endTime": "2023-10-31T09:05:36.79987142Z", "target": "projects/HOST_PROJECT_ID/locations/us-central1/imageImports/IMPORT_NAME", "verb": "create", "apiVersion": "v1", "@type": "type.googleapis.com/google.cloud.vmmigration.v1.OperationMetadata" } }Monitor the machine image import job for completion using the followingcommand.
GET https://vmmigration.googleapis.com/v1/projects/HOST_PROJECT_ID/locations/REGION_ID/imageImports/IMPORT_NAME/imageImportJobs/image-import-job
Replace the following:
HOST_PROJECT_ID: the name of the host projectfrom which you are migrating the machine image.REGION_ID: the region in which you want themachine image import process to run. The machine image is created in theclosest multi-region. If you want the machine image to be created in aregion, verify thatsingleRegionStorageis set to true. Fora list of supported regions, seeRegions and Zones.IMPORT_NAME: the ID that represents the machineimage import resource. When you import an machine image toCompute Engine, Migrate to Virtual Machines creates an first creates anmachine image import resource. The machine image import resourcerepresents the machine image import process. You can use theIMPORT_NAMEto get the link to the machine imagethat was imported as part of the machine image import process.
You should see a job completion response similar to the following sampleresponse.
{ "createTime":"2023-10-31T09:12:27.053788394Z", "createdResources":[ "https://www.googleapis.com/compute/v1/projects/USER_PROJECT/global/images/IMAGE_NAME" ], "diskImageTargetDetails": { "imageName":"IMAGE_NAME", "targetProject":"projects/HOST_PROJECT_ID/locations/global/targetProjects/TARGET_PROJECT" }, "endTime":"2023-10-31T09:16:50.224865783Z", "name":"projects/HOST_PROJECT_ID/locations/us-central1/imageImports/IMPORT_NAME/imageImportJobs/image-import-job", "state":"SUCCEEDED"}
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.