summary import { Image , ComputeManagementClient } from "@msinternal/compute-resource-manager" ; import { DefaultAzureCredential } from "@azure/identity" ; async function createAVirtualMachineImageFromAnExistingVirtualMachine ( ) { const subscriptionId = "{subscription-id}" ; const resourceGroupName = "myResourceGroup" ; const imageName = "myImage" ; const parameters = { location : "West US" , sourceVirtualMachine : { id : "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM" } } ; const credential = new DefaultAzureCredential ( ) ; const client = new ComputeManagementClient ( credential , subscriptionId ) ; const result = await client . images . beginCreateOrUpdateAndWait ( resourceGroupName , imageName , parameters ) ; console . log ( result ) ; } createAVirtualMachineImageFromAnExistingVirtualMachine ( ) . catch ( console . error ) ;