After swapping OS disk, the resource ID should be updated. If you are not following that, make sure to do that.
Folowing is an example PowerShell script.
# Get the VM
$vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
# (Optional) Stop/ deallocate the VM
Stop-AzVM -ResourceGroupName myResourceGroup -Name $vm.Name -Force
# Get the new disk that you want to swap in
$disk = Get-AzDisk -ResourceGroupName myResourceGroup -Name newDisk
# Set the VM configuration to point to the new disk
Set-AzVMOSDisk -VM $vm -ManagedDiskId $disk.Id -Name $disk.Name
# Update the VM with the new OS disk
Update-AzVM -ResourceGroupName myResourceGroup -VM $vm
# Start the VM
Start-AzVM -Name $vm.Name -ResourceGroupName myResourceGroup
----------
--please don't forget to upvote
and Accept as answer
if the reply is helpful--