Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

Snapshot copy using az snapshot create does not copy property "Trusted Launch" #28457

Open martin-merdes opened 8 months ago

martin-merdes commented 8 months ago

Describe the bug

When creating an incremental snapshot from an OS disk of a VM that uses Trusted Launch, the property "Trusted Launch" is set for the snapshot, too. When copying this snapshot using az snapshot create, the property "Trusted Launch" goes away. This results in a failure when creating a new VM from the copied snapshot.

Related command

az snapshot create -g 'martinme_repro_ssc5_target' -n 'osdisk.snapshot.target' --source "/subscriptions/e663cc2d-722b-4be1-b636bbd9e4c60fd9/resourceGroups/martinme_repro_ssc5_source/providers/Microsoft.Compute/snapshots/osdisk.snapshot.source" --copy-start --incremental -l eastus

Errors

az snapshot create does not return any error but its result is wrong. Follow-up error because az snapshot create did not work correctly:

New-AzResourceGroupDeployment -ResourceGroupName $rgname_target -Temp … | ~~~~~~~~~~~~~~~~~ | 1:18:30 PM - The deployment 'dc97fd09-3bf3-4063-914c-310a11774d92' failed with error(s). Showing 1 out of 1 | error(s). Status Message: Security type of VM is not compatible with the security type of attached OS Disk. | (Code:BadRequest) CorrelationId: f958dea6-b50a-4cd9-8f07-fa44cee34980

Issue script & Debug output

This issue is related to https://github.com/Azure/azure-powershell/issues/24242

You can use the repro script from that issue and simply replace:

$config = New-AzSnapshotConfig -SourceResourceId $sourceSnapshot.Id -CreateOption 'CopyStart' -Location $location -Incremental $targetSnapshot = New-AzSnapshot -SnapshotName $snapshotNameTarget -ResourceGroupName $rgname_target -Snapshot $config

with: az snapshot create -g 'martinme_repro_ssc5_target' -n 'osdisk.snapshot.target' --source "/subscriptions/e663cc2d-722b-4be1-b636-bbd9e4c60fd9/resourceGroups/martinme_repro_ssc5_source/providers/Microsoft.Compute/snapshots/osdisk.snapshot.source" --copy-start --incremental -l eastus

Expected behavior

az snapshot create should check all properties of the source snapshot and set it in the copied snapshot, too.

Environment Summary

azure-cli 2.57.0

core 2.57.0 telemetry 1.1.0

Extensions: ai-examples 0.2.5 bastion 0.2.3 ml 2.22.0 ssh 2.0.2

Dependencies: msal 1.26.0 azure-mgmt-resource 23.1.0b

Additional context

No response

yonzhan commented 8 months ago

Thank you for opening this issue, we will look into it.