Hello sns
There is a PowerShell command to move an image from one VM image definition in a computer gallery to another VM image definition in a computer gallery in a different subscription. The command is called Export-AzureComputeGalleryImageVersion
and Import-AzureComputeGalleryImageVersion
.
To use the commands, you will need to have the following:
- The Azure PowerShell module installed.
- The subscription ID of the source and destination subscriptions.
- The name of the source and destination computer galleries.
- The name of the source and destination VM image definitions.
Here are the steps on how to move an image from one VM image definition in a computer gallery to another VM image definition in a computer gallery in a different subscription using PowerShell:
- Export the image from the source VM image definition:
PowerShell
Export-AzureComputeGalleryImageVersion -SubscriptionId <source_subscription_id> -ComputerGalleryName <source_computer_gallery_name> -ImageDefinitionName <source_image_definition_name> -Version <source_image_version> -OutputFile <output_file_path>
Use code with caution. Learn more
content_copy
- Import the image to the destination VM image definition:
PowerShell
Import-AzureComputeGalleryImageVersion -SubscriptionId <destination_subscription_id> -ComputerGalleryName <destination_computer_gallery_name> -ImageDefinitionName <destination_image_definition_name> -InputFile <input_file_path>
Use code with caution. Learn more
content_copy
Here is an example of how to use the commands:
PowerShell
# Export the image from the source VM image definition
Export-AzureComputeGalleryImageVersion -SubscriptionId <source_subscription_id> -ComputerGalleryName <source_computer_gallery_name> -ImageDefinitionName <source_image_definition_name> -Version <source_image_version> -OutputFile C:\Temp\image.vhd
# Import the image to the destination VM image definition
Import-AzureComputeGalleryImageVersion -SubscriptionId <destination_subscription_id> -ComputerGalleryName <destination_computer_gallery_name> -ImageDefinitionName <destination_image_definition_name> -InputFile C:\Temp\image.vhd
Use code with caution. Learn more
content_copy
Once the image has been imported to the destination VM image definition, you can deploy a virtual machine from the image.
I hope this helps! Let me know if you have any other questions.