Skip to content

Commit d8dfe97

Browse files
committed
Adding a fix to allow encryption only on data volumes for linux VMs
1 parent 8bcf538 commit d8dfe97

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/SetAzureDiskEncryptionExtension.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,20 @@ public override void ExecuteCmdlet()
411411
this.ResourceGroupName, VMName).Body;
412412

413413
currentOSType = virtualMachineResponse.StorageProfile.OsDisk.OsType;
414+
415+
if (OperatingSystemTypes.Linux.Equals(currentOSType) &&
416+
!AzureDiskEncryptionExtensionContext.VolumeTypeData.Equals(VolumeType, StringComparison.InvariantCultureIgnoreCase))
417+
{
418+
ThrowTerminatingError(
419+
new ErrorRecord(
420+
new ArgumentException(
421+
string.Format(
422+
CultureInfo.CurrentUICulture,
423+
"Enabling encryption is only allowed on Data volumes for Linux VMs.")),
424+
"InvalidType",
425+
ErrorCategory.NotImplemented,
426+
null));
427+
}
414428

415429
if (OperatingSystemTypes.Linux.Equals(currentOSType))
416430
{

0 commit comments

Comments
 (0)