Skip to content

Commit 2840af4

Browse files
committed
add code for encrypt format all
1 parent f4980aa commit 2840af4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static class AzureDiskEncryptionExtensionConstants
2222
public const string aadClientCertParameterSet = "AADClientCertParameterSet";
2323
public const string aadClientSecretParameterSet = "AADClientSecretParameterSet";
2424
public const string enableEncryptionOperation = "EnableEncryption";
25+
public const string enableEncryptionFormatAllOperation = "EnableEncryptionFormatAll";
2526
public const string disableEncryptionOperation = "DisableEncryption";
2627
public const string queryEncryptionStatusOperation = "QueryEncryptionStatus";
2728
public const string encryptionResultOsKey = "os";

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ public class SetAzureDiskEncryptionExtensionCommand : VirtualMachineExtensionBas
193193
[ValidateNotNullOrEmpty]
194194
public string ExtensionPublisherName { get; set; }
195195

196+
[Parameter(
197+
Mandatory = false,
198+
Position = 18,
199+
ValueFromPipelineByPropertyName = true,
200+
HelpMessage = "Encrypt-Format all data drives that are not already encrypted")]
201+
public SwitchParameter EncryptFormatAll { get; set; }
202+
196203
private OperatingSystemTypes? currentOSType = null;
197204

198205
private void ValidateInputParameters()
@@ -387,9 +394,17 @@ private Hashtable GetExtensionPublicSettings()
387394
publicSettings.Add(AzureDiskEncryptionExtensionConstants.keyVaultUrlKey, DiskEncryptionKeyVaultUrl ?? String.Empty);
388395
publicSettings.Add(AzureDiskEncryptionExtensionConstants.keyEncryptionKeyUrlKey, KeyEncryptionKeyUrl ?? String.Empty);
389396
publicSettings.Add(AzureDiskEncryptionExtensionConstants.volumeTypeKey, VolumeType ?? String.Empty);
390-
publicSettings.Add(AzureDiskEncryptionExtensionConstants.encryptionOperationKey, AzureDiskEncryptionExtensionConstants.enableEncryptionOperation);
391397
publicSettings.Add(AzureDiskEncryptionExtensionConstants.sequenceVersionKey, SequenceVersion ?? String.Empty);
392398

399+
if (EncryptFormatAll)
400+
{
401+
publicSettings.Add(AzureDiskEncryptionExtensionConstants.encryptionOperationKey, AzureDiskEncryptionExtensionConstants.enableEncryptionFormatAllOperation);
402+
}
403+
else
404+
{
405+
publicSettings.Add(AzureDiskEncryptionExtensionConstants.encryptionOperationKey, AzureDiskEncryptionExtensionConstants.enableEncryptionOperation);
406+
}
407+
393408
string keyEncryptAlgorithm = string.Empty;
394409
if (!string.IsNullOrEmpty(this.KeyEncryptionKeyUrl))
395410
{

0 commit comments

Comments
 (0)