Hi Allan Guerreiro,
Make sure you are taking a snapshot of the OS disk and then creating VM with set OS disk command:
Example:
Taking Snapshot:
# --- Parameters ---
$resourceGroupName = "<Your Resource Group Name>"
$vmName = "<Your VM Name>"
$snapshotName = "<Desired Snapshot Name>"
$location = "<Your Azure Region>" # e.g., "eastus"
# --- Get the VM and OS Disk ID ---
$vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmName
$osDiskId = $vm.StorageProfile.OsDisk.ManagedDisk.Id
# --- Create the Snapshot Configuration ---
$snapshotConfig = New-AzSnapshotConfig `
-SourceUri $osDiskId `
-CreateOption Copy `
-Location $location
# --- Create the Snapshot ---
New-AzSnapshot `
-Snapshot $snapshotConfig `
-SnapshotName $snapshotName `
-ResourceGroupName $resourceGroupName
Create a managed disk from snapshot:
https://learn.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-powershell-sample-create-managed-disk-from-snapshot#sample-script
Create a VM from managed disk:
https://learn.microsoft.com/en-us/previous-versions/azure/virtual-machines/scripts/virtual-machines-powershell-sample-create-vm-from-managed-os-disks?toc=%2Fpowershell%2Fmodule%2Ftoc.json#sample-script
Regards,
Sarthak.