Skip to content

Commit d8212ae

Browse files
authored
Deprecate DisableSoftDelete in New-AzKeyVault & EnableSoftDelete in Update-AzKeyVault (#13224)
* deprecate DisableSoftDelete & EnableSoftDelete * update help markdown * suppress breaking change issues
1 parent 8bb3743 commit d8212ae

File tree

12 files changed

+352
-1192
lines changed

12 files changed

+352
-1192
lines changed

src/KeyVault/KeyVault.Test/Scripts/ControlPlane/KeyVaultManagementTests.ps1

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ function Test-CreateNewVault {
127127
Assert-AreEqual $true $actual.EnabledForDeployment
128128
Assert-AreEqual 0 @($actual.AccessPolicies).Count
129129

130-
# Test disable soft delete
131-
$actual = New-AzKeyVault -VaultName $vault3Name -ResourceGroupName $rgName -Location $vaultLocation -Sku standard -DisableSoftDelete
132-
Assert-False { $actual.EnableSoftDelete }
133-
Assert-Null $actual.EnablePurgeProtection "If -DisableSoftDelete, EnablePurgeProtection should be null"
134-
Assert-Null $actual.SoftDeleteRetentionInDays "If -DisableSoftDelete, SoftDeleteRetentionInDays should be null"
135-
136130
# Test enable purge protection & customize retention days
137131
$actual = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $rgName -Location $vaultLocation -Sku standard -EnablePurgeProtection -SoftDeleteRetentionInDays 10
138132
Assert-True { $actual.EnableSoftDelete } "By default EnableSoftDelete should be true"
@@ -143,9 +137,6 @@ function Test-CreateNewVault {
143137
$actual = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $rgName -Location $vaultLocation -EnableRbacAuthorization
144138
Assert-True { $actual.EnableRbacAuthorization } "If specified, EnableRbacAuthorization should be true"
145139

146-
# # Test use -DisableSoftDelete -EnablePurgeProtection together (TODO: uncomment this assert after keyvault team deploys their fix)
147-
# Assert-Throws { New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $rgName -Location $vaultLocation -Sku standard -DisableSoftDelete -EnablePurgeProtection }
148-
149140
# Test positional parameters
150141
$actual = New-AzKeyVault $vault4Name $rgName $vaultLocation
151142
Assert-NotNull $actual
@@ -784,32 +775,16 @@ function Test-UpdateKeyVault {
784775

785776
try {
786777
$rg = New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation
787-
$vault = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $resourceGroupName -Location $vaultLocation -DisableSoftDelete
788-
Assert-True { $vault.EnableSoftDelete -ne $true } "1. EnableSoftDelete should not be true"
789-
Assert-True { $vault.EnablePurgeProtection -ne $true } "1. EnablePurgeProtection should not be true"
790-
791-
# Enable soft delete first
792-
$vault = $vault | Update-AzKeyVault -EnableSoftDelete
793-
Assert-True { $vault.EnableSoftDelete } "2. EnableSoftDelete should be true"
794-
Assert-True { $vault.EnablePurgeProtection -ne $true } "2. EnablePurgeProtection should not be true"
795-
Assert-AreEqual 90 $vault.SoftDeleteRetentionInDays "2. SoftDeleteRetentionInDays should default to 90"
796-
797-
# Enable again
798-
$vault = $vault | Update-AzKeyVault -EnableSoftDelete
799-
Assert-True { $vault.EnableSoftDelete } "2.5. EnableSoftDelete should be true"
800-
Assert-True { $vault.EnablePurgeProtection -ne $true } "2.5. EnablePurgeProtection should not be true"
778+
$originVault = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $resourceGroupName -Location $vaultLocation
779+
Assert-True { $originVault.EnableSoftDelete } "1. EnableSoftDelete should be true"
780+
Assert-True { $originVault.EnablePurgeProtection -ne $true } "1. EnablePurgeProtection should not be true"
781+
Assert-AreEqual 90 $originVault.SoftDeleteRetentionInDays "1. SoftDeleteRetentionInDays should default to 90"
801782

802783
# Then enable purge protection
803-
$vault = $vault | Update-AzKeyVault -EnablePurgeProtection
784+
$vault = $originVault | Update-AzKeyVault -EnablePurgeProtection
804785
Assert-True { $vault.EnableSoftDelete } "3. EnableSoftDelete should be true"
805786
Assert-True { $vault.EnablePurgeProtection } "3. EnablePurgeProtection should be true"
806-
807-
# Enable both together (& custom retention days)
808-
$vault = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $resourceGroupName -Location $vaultLocation -DisableSoftDelete
809-
$vault = $vault | Update-AzKeyVault -EnableSoftDelete -EnablePurgeProtection -SoftDeleteRetentionInDays 77
810-
Assert-True { $vault.EnableSoftDelete } "4. EnableSoftDelete should be true"
811-
Assert-True { $vault.EnablePurgeProtection } "4. EnablePurgeProtection should be true"
812-
Assert-AreEqual 77 $vault.SoftDeleteRetentionInDays "4. SoftDeleteRetentionInDays should be updated"
787+
Assert-True { $vault.SoftDeleteRetentionInDays -eq $originVault.SoftDeleteRetentionInDays }
813788

814789
# # Only enable purge protection (TODO: uncomment this assert after keyvault team deploys their fix)
815790
# $vault = New-AzKeyVault -VaultName (getAssetName) -ResourceGroupName $resourceGroupName -Location $vaultLocation

src/KeyVault/KeyVault.Test/SessionRecords/Microsoft.Azure.Commands.KeyVault.Test.ScenarioTests.KeyVaultManagementTests/TestUpdateVault.json

Lines changed: 315 additions & 1048 deletions
Large diffs are not rendered by default.

src/KeyVault/KeyVault/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Deprecated parameter DisableSoftDelete in `New-AzKeyVault` and EnableSoftDelete in `Update-AzKeyVault`
2122
* Removed attribute SecretValueText to avoid displaying SecretValue directly [#12266]
2223

2324
## Version 2.2.1

src/KeyVault/KeyVault/Commands/NewAzureKeyVault.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616
using Microsoft.Azure.Commands.KeyVault.Properties;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.Azure.Management.KeyVault.Models;
19-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2019
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2120
using System;
2221
using System.Collections;
23-
using System.Linq;
2422
using System.Management.Automation;
2523

2624
namespace Microsoft.Azure.Commands.KeyVault
2725
{
2826
/// <summary>
2927
/// Create a new key vault.
3028
/// </summary>
31-
[GenericBreakingChange("The ability to create new key vaults with soft delete disabled will be deprecated by December 2020. " +
32-
"All key vaults will be required to have soft delete enabled. Please see the following documentation for additional guidance. " +
33-
"https://docs.microsoft.com/azure/key-vault/general/soft-delete-change")]
3429
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "KeyVault", SupportsShouldProcess = true)]
3530
[OutputType(typeof(PSKeyVault))]
3631
public class NewAzureKeyVault : KeyVaultManagementCmdletBase
@@ -87,13 +82,6 @@ public class NewAzureKeyVault : KeyVaultManagementCmdletBase
8782
HelpMessage = "If specified, enables secrets to be retrieved from this key vault by Azure Disk Encryption.")]
8883
public SwitchParameter EnabledForDiskEncryption { get; set; }
8984

90-
public const String DisableSoftDeleteChangeDesc = "DisableSoftDelete will be deprecated without being replaced.";
91-
92-
[CmdletParameterBreakingChange("DisableSoftDelete", "3.0.0", ChangeDescription = DisableSoftDeleteChangeDesc)]
93-
[Parameter(Mandatory = false,
94-
HelpMessage = "If specified, 'soft delete' functionality is disabled for this key vault.")]
95-
public SwitchParameter DisableSoftDelete { get; set; }
96-
9785
[Parameter(Mandatory = false,
9886
HelpMessage = "If specified, protection against immediate deletion is enabled for this vault; requires soft delete to be enabled as well. Enabling 'purge protection' on a key vault is an irreversible action. Once enabled, it cannot be changed or removed.")]
9987
public SwitchParameter EnablePurgeProtection { get; set; }
@@ -170,20 +158,16 @@ public override void ExecuteCmdlet()
170158
EnabledForDeployment = this.EnabledForDeployment.IsPresent,
171159
EnabledForTemplateDeployment = EnabledForTemplateDeployment.IsPresent,
172160
EnabledForDiskEncryption = EnabledForDiskEncryption.IsPresent,
173-
EnableSoftDelete = !DisableSoftDelete.IsPresent,
161+
EnableSoftDelete = null,
174162
EnablePurgeProtection = EnablePurgeProtection.IsPresent ? true : (bool?)null, // false is not accepted
175163
EnableRbacAuthorization = EnableRbacAuthorization.IsPresent,
176-
177164
/*
178-
* If soft delete is enabled, but retention days is not specified, use the default value,
179-
* else use the vault user provides,
180-
* else use null
165+
* If retention days is not specified, use the default value,
166+
* else use the vault user provides
181167
*/
182-
SoftDeleteRetentionInDays = DisableSoftDelete.IsPresent
183-
? null as int?
184-
: (this.IsParameterBound(c => c.SoftDeleteRetentionInDays)
168+
SoftDeleteRetentionInDays = this.IsParameterBound(c => c.SoftDeleteRetentionInDays)
185169
? SoftDeleteRetentionInDays
186-
: Constants.DefaultSoftDeleteRetentionDays),
170+
: Constants.DefaultSoftDeleteRetentionDays,
187171
SkuFamilyName = DefaultSkuFamily,
188172
SkuName = this.Sku,
189173
TenantId = GetTenantId(),

src/KeyVault/KeyVault/Commands/RemoveAzureKeyVault.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
using Microsoft.Azure.Commands.KeyVault.Properties;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1818
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
19-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2019
using System;
2120
using System.Globalization;
2221
using System.Management.Automation;
2322

2423
namespace Microsoft.Azure.Commands.KeyVault
2524
{
26-
[GenericBreakingChange("If you have soft-delete protection enabled on this key vault, you will not be able to reuse this key vault name until the key vault has been purged from the soft deleted state. " +
27-
"Please see the following documentation for additional guidance. https://docs.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview")]
2825
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "KeyVault",SupportsShouldProcess = true,DefaultParameterSetName = RemoveVaultParameterSet)]
2926
[OutputType(typeof(bool))]
3027
public class RemoveAzureKeyVault : KeyVaultManagementCmdletBase

src/KeyVault/KeyVault/Commands/RemoveAzureKeyVaultCertificate.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Globalization;
16-
using System.Management.Automation;
1715
using Microsoft.Azure.Commands.KeyVault.Models;
1816
using Microsoft.Azure.Commands.KeyVault.Properties;
1917
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
20-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
18+
using System.Globalization;
19+
using System.Management.Automation;
2120

2221
namespace Microsoft.Azure.Commands.KeyVault
2322
{
2423
/// <summary>
2524
/// The Remove-AzKeyVaultCertificate cmdlet deletes a certificate in an Azure Key Vault.
2625
/// </summary>
27-
[GenericBreakingChange("If you have soft-delete protection enabled on this key vault, this certificate will be moved to the soft deleted state. " +
28-
"You will not be able to create a certificate with the same name within this key vault until the certificate has been purged from the soft-deleted state. " +
29-
"Please see the following documentation for additional guidance. https://docs.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview")]
3026
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzurePrefix + "KeyVaultCertificate",SupportsShouldProcess = true,DefaultParameterSetName = ByVaultNameAndNameParameterSet)]
3127
[OutputType(typeof(PSDeletedKeyVaultCertificate))]
3228
public class RemoveAzureKeyVaultCertificate : KeyVaultCmdletBase

src/KeyVault/KeyVault/Commands/RemoveAzureKeyVaultKey.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.KeyVault.Models;
16-
using System.Globalization;
17-
using System.Management.Automation;
1816
using Microsoft.Azure.Commands.KeyVault.Properties;
1917
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
20-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
18+
using System.Globalization;
19+
using System.Management.Automation;
2120

2221
namespace Microsoft.Azure.Commands.KeyVault
2322
{
24-
[GenericBreakingChange("If you have soft - delete protection enabled on this key vault, this key will be moved to the soft deleted state. " +
25-
"You will not be able to create a key with the same name within this key vault until the key has been purged from the soft-deleted state. " +
26-
"Please see the following documentation for additional guidance.https://docs.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview")]
2723
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzurePrefix + "KeyVaultKey",SupportsShouldProcess = true,DefaultParameterSetName = ByVaultNameParameterSet)]
2824
[OutputType(typeof(PSDeletedKeyVaultKey))]
2925
public class RemoveAzureKeyVaultKey : KeyVaultCmdletBase

src/KeyVault/KeyVault/Commands/UpdateAzureKeyVault.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,13 @@ public class UpdateTopLevelResourceCommand : KeyVaultManagementCmdletBase
4949
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = UpdateByResourceIdParameterSet, HelpMessage = "Resource ID of the key vault.")]
5050
[ValidateNotNullOrEmpty]
5151
public string ResourceId { get; set; }
52-
53-
public const String EnableSoftDeleteChangeDesc = "EnableSoftDelete will be deprecated without being replaced.";
54-
55-
[CmdletParameterBreakingChange("EnableSoftDelete", "3.0.0", ChangeDescription = EnableSoftDeleteChangeDesc)]
56-
[Parameter(Mandatory = false, HelpMessage = "Enable the soft-delete functionality for this key vault. Once enabled it cannot be disabled.")]
57-
public SwitchParameter EnableSoftDelete { get; set; }
58-
52+
5953
[Parameter(Mandatory = false, HelpMessage = "Enable the purge protection functionality for this key vault. Once enabled it cannot be disabled. It requires soft-delete to be turned on.")]
6054
public SwitchParameter EnablePurgeProtection { get; set; }
6155

6256
[Parameter(Mandatory = false, HelpMessage = "Enable or disable this key vault to authorize data actions by Role Based Access Control (RBAC).")]
6357
public bool? EnableRbacAuthorization { get; set; }
6458

65-
[Parameter(Mandatory = false, HelpMessage = "Specifies how long deleted resources are retained, and how long until a vault or an object in the deleted state can be purged. The default is " + Constants.DefaultSoftDeleteRetentionDaysString + " days.")]
66-
[ValidateRange(Constants.MinSoftDeleteRetentionDays, Constants.MaxSoftDeleteRetentionDays)]
67-
[ValidateNotNullOrEmpty]
68-
public int SoftDeleteRetentionInDays { get; set; }
69-
7059
public override void ExecuteCmdlet()
7160
{
7261
if (this.IsParameterBound(c => c.InputObject))
@@ -104,12 +93,10 @@ public override void ExecuteCmdlet()
10493
existingResource.EnabledForDeployment,
10594
existingResource.EnabledForTemplateDeployment,
10695
existingResource.EnabledForDiskEncryption,
107-
EnableSoftDelete.IsPresent ? (true as bool?) : null,
96+
null,
10897
EnablePurgeProtection.IsPresent ? (true as bool?) : null,
10998
EnableRbacAuthorization,
110-
this.IsParameterBound(c => c.SoftDeleteRetentionInDays)
111-
? (SoftDeleteRetentionInDays as int?)
112-
: (existingResource.SoftDeleteRetentionInDays ?? Constants.DefaultSoftDeleteRetentionDays),
99+
null,
113100
existingResource.NetworkAcls
114101
);
115102

src/KeyVault/KeyVault/KeyVault.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@
378378
<Label>Soft Delete Retention Period (days)</Label>
379379
<PropertyName>SoftDeleteRetentionInDays</PropertyName>
380380
</ListItem>
381+
<ListItem>
382+
<Label>Enabled Purge Protection?</Label>
383+
<PropertyName>EnablePurgeProtection</PropertyName>
384+
</ListItem>
381385
<ListItem>
382386
<Label>Access Policies</Label>
383387
<PropertyName>AccessPoliciesText</PropertyName>

src/KeyVault/KeyVault/help/New-AzKeyVault.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Creates a key vault.
1515

1616
```
1717
New-AzKeyVault [-Name] <String> [-ResourceGroupName] <String> [-Location] <String> [-EnabledForDeployment]
18-
[-EnabledForTemplateDeployment] [-EnabledForDiskEncryption] [-DisableSoftDelete] [-EnablePurgeProtection]
18+
[-EnabledForTemplateDeployment] [-EnabledForDiskEncryption] [-EnablePurgeProtection]
1919
[-EnableRbacAuthorization] [-SoftDeleteRetentionInDays <Int32>] [-Sku <SkuName>] [-Tag <Hashtable>]
2020
[-NetworkRuleSet <PSKeyVaultNetworkRuleSet>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
2121
[<CommonParameters>]
@@ -135,21 +135,6 @@ Accept pipeline input: False
135135
Accept wildcard characters: False
136136
```
137137
138-
### -DisableSoftDelete
139-
If specified, 'soft delete' functionality is disabled for this key vault.
140-
141-
```yaml
142-
Type: System.Management.Automation.SwitchParameter
143-
Parameter Sets: (All)
144-
Aliases:
145-
146-
Required: False
147-
Position: Named
148-
Default value: None
149-
Accept pipeline input: False
150-
Accept wildcard characters: False
151-
```
152-
153138
### -EnabledForDeployment
154139
Enables the Microsoft.Compute resource provider to retrieve secrets from this key vault when this
155140
key vault is referenced in resource creation, for example when creating a virtual machine.

src/KeyVault/KeyVault/help/Update-AzKeyVault.md

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,28 @@ Update the state of an Azure key vault.
1414

1515
### UpdateByNameParameterSet (Default)
1616
```
17-
Update-AzKeyVault -ResourceGroupName <String> -VaultName <String> [-EnableSoftDelete] [-EnablePurgeProtection]
18-
[-EnableRbacAuthorization <Boolean>] [-SoftDeleteRetentionInDays <Int32>]
19-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
17+
Update-AzKeyVault -ResourceGroupName <String> -VaultName <String> [-EnablePurgeProtection]
18+
[-EnableRbacAuthorization <Boolean>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
19+
[<CommonParameters>]
2020
```
2121

2222
### UpdateByInputObjectParameterSet
2323
```
24-
Update-AzKeyVault -InputObject <PSKeyVault> [-EnableSoftDelete] [-EnablePurgeProtection]
25-
[-EnableRbacAuthorization <Boolean>] [-SoftDeleteRetentionInDays <Int32>]
24+
Update-AzKeyVault -InputObject <PSKeyVault> [-EnablePurgeProtection] [-EnableRbacAuthorization <Boolean>]
2625
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2726
```
2827

2928
### UpdateByResourceIdParameterSet
3029
```
31-
Update-AzKeyVault -ResourceId <String> [-EnableSoftDelete] [-EnablePurgeProtection]
32-
[-EnableRbacAuthorization <Boolean>] [-SoftDeleteRetentionInDays <Int32>]
30+
Update-AzKeyVault -ResourceId <String> [-EnablePurgeProtection] [-EnableRbacAuthorization <Boolean>]
3331
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3432
```
3533

3634
## DESCRIPTION
3735
This cmdlet updates the state of an Azure key vault.
38-
Please note updating some of the properties is an irreversible action, for example once soft delete has been enabled, it cannot be disabled anymore.
3936

4037
## EXAMPLES
4138

42-
### Example 1
43-
```powershell
44-
PS C:\> Update-AzKeyVault -VaultName $keyVaultName -ResourceGroupName $resourceGroupName -EnableSoftDelete
45-
```
46-
47-
Enables soft delete on the key vault named `$keyVaultName` in resource group `$resourceGroupName`.
4839

4940
### Example 1
5041
```powershell
@@ -102,22 +93,6 @@ Accept pipeline input: False
10293
Accept wildcard characters: False
10394
```
10495
105-
### -EnableSoftDelete
106-
Enable the soft-delete functionality for this key vault.
107-
Once enabled it cannot be disabled.
108-
109-
```yaml
110-
Type: System.Management.Automation.SwitchParameter
111-
Parameter Sets: (All)
112-
Aliases:
113-
114-
Required: False
115-
Position: Named
116-
Default value: None
117-
Accept pipeline input: False
118-
Accept wildcard characters: False
119-
```
120-
12196
### -InputObject
12297
Key vault object.
12398
@@ -163,21 +138,6 @@ Accept pipeline input: True (ByPropertyName)
163138
Accept wildcard characters: False
164139
```
165140
166-
### -SoftDeleteRetentionInDays
167-
Specifies how long deleted resources are retained, and how long until a vault or an object in the deleted state can be purged. The default is 90 days.
168-
169-
```yaml
170-
Type: System.Int32
171-
Parameter Sets: (All)
172-
Aliases:
173-
174-
Required: False
175-
Position: Named
176-
Default value: None
177-
Accept pipeline input: False
178-
Accept wildcard characters: False
179-
```
180-
181141
### -VaultName
182142
Name of the key vault.
183143

0 commit comments

Comments
 (0)