Azure Compute Image Gallery – Copy Compute Images across subscriptions/Tenants

Following powershell module can be used to copy Managed Images from one Gallery to another (across Subscriptions or Tenants).

#Set variables

#Set variables$targetSubID = “<subscription ID for the target>”
$sourceTenantID = “<tenant ID where for the source image>”
$sourceImageID = “<resource ID of the source image>”

#Login to the tenant where the source image is published
Connect-AzAccount -Tenant $sourceTenantID -UseDeviceAuthentication

#Login to the subscription where the new image will be created and set the context
Connect-AzAccount -UseDeviceAuthentication -Subscription $targetSubID
Set-AzContext -Subscription $targetSubID

#Create the image version from another image version in a different tenant
New-AzGalleryImageVersion -ResourceGroupName myResourceGroup -GalleryName myGallery -GalleryImageDefinitionName myImageDef -Location “West US 2” -Name 1.0.0 -SourceImageId $sourceImageID

Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/image-version?tabs=powershell%2Cpowershell2#create-an-image-in-one-tenant-using-the-source-image-in-another-tenant