Skip to content

Commit 566112d

Browse files
authored
[Breaking Change] Changed parameter SoftDeleteRetentionInDays in New-AzKeyVaultManagedHsm (#22856)
* [Breaking Change] Changed parameter SoftDeleteRetentionInDays in New-AzKeyVaultManagedHsm to mandatory * update examples * update test cases * Update BreakingChangeIssues.csv
1 parent 7bfeb33 commit 566112d

File tree

5 files changed

+51
-52
lines changed

5 files changed

+51
-52
lines changed

src/KeyVault/KeyVault.Test/ScenarioTests/ManagedHsmManagementTests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Test-ManagedHsmCRUD {
2626

2727
try {
2828
# Test create a default managed HSM
29-
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator
29+
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90
3030
Assert-AreEqual $hsmName $hsm.Name
3131
Assert-AreEqual $rgName $hsm.ResourceGroupName
3232
Assert-AreEqual $hsmLocation $hsm.Location
@@ -46,15 +46,15 @@ function Test-ManagedHsmCRUD {
4646
Assert-NotNull $got.SecurityDomain
4747

4848
# Test throws for existing managed HSM
49-
Assert-Throws { New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator }
49+
Assert-Throws { New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90}
5050

5151
# Test remove managed HSM
5252
Remove-AzKeyVaultManagedHsm -InputObject $got -Force
5353
$deletedMhsm = Get-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName
5454
Assert-Null $deletedMhsm
5555

5656
# Test throws for resourcegroup nonexistent
57-
Assert-Throws { New-AzKeyVaultManagedHsm -Name (getAssetName) -ResourceGroupName (getAssetName) -Location $hsmLocation -Administrator $administrator }
57+
Assert-Throws { New-AzKeyVaultManagedHsm -Name (getAssetName) -ResourceGroupName (getAssetName) -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90}
5858
}
5959

6060
finally {
@@ -83,15 +83,15 @@ function Test-CreateManagedHsmWithPublicNetworkAccess{
8383
New-AzResourceGroup -Name $rgName -Location $rgLocation
8484
try {
8585
# Test creating a default managed HSM
86-
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator
86+
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90
8787
Assert-AreEqual "Enabled" $hsm.PublicNetworkAccess "1. The default of PublicNetworkAccess is Enabled"
8888

8989
# Test create a managed HSM with disabled PublicNetworkAccess
90-
$hsm2 = New-AzKeyVaultManagedHsm -Name $hsmName2 -ResourceGroupName $rgName -Location $hsmLocation2 -Administrator $administrator -PublicNetworkAccess Disabled
90+
$hsm2 = New-AzKeyVaultManagedHsm -Name $hsmName2 -ResourceGroupName $rgName -Location $hsmLocation2 -Administrator $administrator -PublicNetworkAccess Disabled -SoftDeleteRetentionInDays 90
9191
Assert-AreEqual "Disabled" $hsm2.PublicNetworkAccess "2. create managed HSM with disabled PublicNetworkAccess"
9292

9393
# Test create a managed HSM with enabled PublicNetworkAccess
94-
$hsm3 = New-AzKeyVaultManagedHsm -Name $hsmName3 -ResourceGroupName $rgName -Location $hsmLocation3 -Administrator $administrator -PublicNetworkAccess Enabled
94+
$hsm3 = New-AzKeyVaultManagedHsm -Name $hsmName3 -ResourceGroupName $rgName -Location $hsmLocation3 -Administrator $administrator -PublicNetworkAccess Enabled -SoftDeleteRetentionInDays 90
9595
Assert-AreEqual "Enabled" $hsm3.PublicNetworkAccess "3. create managed HSM with enabled PublicNetworkAccess"
9696

9797
}finally{
@@ -116,7 +116,7 @@ function Test-UpdateManagedHsmWithPublicNetworkAccess{
116116
New-AzResourceGroup -Name $rgName -Location $rgLocation
117117
try {
118118
# Test creating a default managed HSM
119-
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator
119+
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90
120120
Assert-AreEqual "Enabled" $hsm.PublicNetworkAccess "1. The default of PublicNetworkAccess is Enabled"
121121

122122
# Test updating PublicNetworkAccess as Disabled
@@ -203,7 +203,7 @@ function Test-UndoManagedHsmRemoval{
203203
New-AzResourceGroup -Name $rgName -Location $rgLocation
204204

205205
# Test: create a managed HSM
206-
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator
206+
$hsm = New-AzKeyVaultManagedHsm -Name $hsmName -ResourceGroupName $rgName -Location $hsmLocation -Administrator $administrator -SoftDeleteRetentionInDays 90
207207

208208
Remove-AzKeyVaultManagedHsm -InputObject $hsm -Force
209209

src/KeyVault/KeyVault/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* [Breaking Change] Changed parameter `SoftDeleteRetentionInDays` in `New-AzKeyVaultManagedHsm` to mandatory.
2122

2223
## Version 4.12.0
2324
* Supported splitting `Import-AzKeyVaultSecurityDomain` process into three steps to allow keys to be hidden offline.
@@ -41,7 +42,7 @@
4142

4243
## Version 4.10.0
4344
* Added breaking change announcement for parameter `SoftDeleteRetentionInDays` in `New-AzKeyVaultManagedHsm`. The parameter `SoftDeleteRetentionInDays` is becoming mandatory
44-
- This change will take effect on version 6.0.0
45+
- This change will take effect on version 5.0.0
4546
* Changed the encoding way from a string into byte array in `Invoke-AzKeyVaultKeyOperation` from ASCII to UTF8. UTF8 is backward-compatible with ASCII. [#21269]
4647
* Bug fix: Changed the decoding way from byte array into a string from system default encoding to UTF8 to match encoding way. [#21269]
4748
* Added parameter `PolicyPath` and `PolicyObject` in `Import-AzKeyVaultCertificate` to support custom policy [#20780]

src/KeyVault/KeyVault/Commands/ManagedHsm/NewAzureManagedHsm.cs renamed to src/KeyVault/KeyVault/Commands/ManagedHsm/NewAzKeyVaultManagedHsm.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Microsoft.Azure.Commands.KeyVault.Commands
3030
/// </summary>
3131
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "KeyVaultManagedHsm", SupportsShouldProcess = true)]
3232
[OutputType(typeof(PSManagedHsm))]
33-
public class NewAzureManagedHsm : KeyVaultManagementCmdletBase
33+
public class NewAzKeyVaultManagedHsm : KeyVaultManagementCmdletBase
3434
{
3535
#region Input Parameter Definitions
3636

@@ -81,8 +81,8 @@ public class NewAzureManagedHsm : KeyVaultManagementCmdletBase
8181
[PSArgumentCompleter("StandardB1", "CustomB32")]
8282
public string Sku { get; set; }
8383

84-
[Parameter(Mandatory = false,
85-
HelpMessage = "Specifies how long the deleted managed hsm pool is retained, and how long until the managed hsm pool in the deleted state can be purged. The default is " + Constants.DefaultSoftDeleteRetentionDaysString + " days.")]
84+
[Parameter(Mandatory = true,
85+
HelpMessage = "Specifies how long the deleted managed hsm pool is retained, and how long until the managed hsm pool in the deleted state can be purged.")]
8686
[ValidateRange(Constants.MinSoftDeleteRetentionDays, Constants.MaxSoftDeleteRetentionDays)]
8787
[ValidateNotNullOrEmpty]
8888
public int SoftDeleteRetentionInDays { get; set; }
@@ -127,9 +127,7 @@ public override void ExecuteCmdlet()
127127
Administrator = this.Administrator,
128128
SkuFamilyName = DefaultManagedHsmSkuFamily,
129129
// If retention days is not specified, use the default value
130-
SoftDeleteRetentionInDays = this.IsParameterBound(c => c.SoftDeleteRetentionInDays)
131-
? SoftDeleteRetentionInDays
132-
: Constants.DefaultSoftDeleteRetentionDays,
130+
SoftDeleteRetentionInDays = this.SoftDeleteRetentionInDays,
133131
// false is not accepted
134132
EnablePurgeProtection = this.EnablePurgeProtection.IsPresent ? true : (bool?)null,
135133
// use default network rule set

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

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ Creates a managed HSM.
1414

1515
```
1616
New-AzKeyVaultManagedHsm [-Name] <String> [-ResourceGroupName] <String> [-Location] <String>
17-
[-Administrator] <String[]> [-Sku <String>] [-SoftDeleteRetentionInDays <Int32>]
18-
[-PublicNetworkAccess <String>] [-EnablePurgeProtection] [-Tag <Hashtable>] [-AsJob]
19-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
20-
[<CommonParameters>]
17+
[-Administrator] <String[]> [-Sku <String>] -SoftDeleteRetentionInDays <Int32> [-PublicNetworkAccess <String>]
18+
[-EnablePurgeProtection] [-Tag <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
19+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
2120
```
2221

2322
## DESCRIPTION
@@ -31,7 +30,7 @@ remove, or list keys in the managed HSM, user should:
3130

3231
### Example 1: Create a StandardB1 managed HSM
3332
```powershell
34-
New-AzKeyVaultManagedHsm -Name 'myhsm' -ResourceGroupName 'myrg1' -Location 'eastus2euap' -Administrator "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
33+
New-AzKeyVaultManagedHsm -Name 'myhsm' -ResourceGroupName 'myrg1' -Location 'eastus2euap' -Administrator "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -SoftDeleteRetentionInDays 70
3534
```
3635

3736
```output
@@ -46,7 +45,7 @@ value for the *SKU* parameter, it creates a Standard_B1 managed HSM.
4645

4746
### Example 2: Create a CustomB32 managed HSM
4847
```powershell
49-
New-AzKeyVaultManagedHsm -Name 'myhsm' -ResourceGroupName 'myrg1' -Location 'eastus2euap' -Administrator "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -Sku 'CustomB32'
48+
New-AzKeyVaultManagedHsm -Name 'myhsm' -ResourceGroupName 'myrg1' -Location 'eastus2euap' -Administrator "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -Sku 'CustomB32' -SoftDeleteRetentionInDays 70
5049
```
5150

5251
```output
@@ -65,7 +64,7 @@ CustomB32 for the *SKU* parameter to create a CustomB32 managed HSM.
6564
Initial administrator object id for this managed HSM pool.
6665

6766
```yaml
68-
Type: System.String[]
67+
Type: String[]
6968
Parameter Sets: (All)
7069
Aliases:
7170

@@ -80,7 +79,7 @@ Accept wildcard characters: False
8079
Run cmdlet in the background
8180
8281
```yaml
83-
Type: System.Management.Automation.SwitchParameter
82+
Type: SwitchParameter
8483
Parameter Sets: (All)
8584
Aliases:
8685

@@ -91,11 +90,26 @@ Accept pipeline input: False
9190
Accept wildcard characters: False
9291
```
9392
93+
### -Confirm
94+
Prompts you for confirmation before running the cmdlet.
95+
96+
```yaml
97+
Type: SwitchParameter
98+
Parameter Sets: (All)
99+
Aliases: cf
100+
101+
Required: False
102+
Position: Named
103+
Default value: None
104+
Accept pipeline input: False
105+
Accept wildcard characters: False
106+
```
107+
94108
### -DefaultProfile
95109
The credentials, account, tenant, and subscription used for communication with Azure.
96110
97111
```yaml
98-
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
112+
Type: IAzureContextContainer
99113
Parameter Sets: (All)
100114
Aliases: AzContext, AzureRmContext, AzureCredential
101115

@@ -110,7 +124,7 @@ Accept wildcard characters: False
110124
specifying whether protection against purge is enabled for this managed HSM pool. The setting is effective only if soft delete is also enabled. Enabling this functionality is irreversible.
111125
112126
```yaml
113-
Type: System.Management.Automation.SwitchParameter
127+
Type: SwitchParameter
114128
Parameter Sets: (All)
115129
Aliases:
116130

@@ -126,7 +140,7 @@ Specifies the Azure region in which to create the key vault.
126140
Use the command Get-AzResourceProvider with the ProviderNamespace parameter to see your choices.
127141
128142
```yaml
129-
Type: System.String
143+
Type: String
130144
Parameter Sets: (All)
131145
Aliases:
132146

@@ -144,7 +158,7 @@ The name must start and end with a letter or digit.
144158
The name must be universally unique.
145159
146160
```yaml
147-
Type: System.String
161+
Type: String
148162
Parameter Sets: (All)
149163
Aliases: HsmName
150164

@@ -159,7 +173,7 @@ Accept wildcard characters: False
159173
Controls permission for data plane traffic coming from public networks while private endpoint is enabled.
160174
161175
```yaml
162-
Type: System.String
176+
Type: String
163177
Parameter Sets: (All)
164178
Aliases:
165179

@@ -174,7 +188,7 @@ Accept wildcard characters: False
174188
Specifies the name of an existing resource group in which to create the key vault.
175189
176190
```yaml
177-
Type: System.String
191+
Type: String
178192
Parameter Sets: (All)
179193
Aliases:
180194

@@ -189,7 +203,7 @@ Accept wildcard characters: False
189203
Specifies the SKU of the managed HSM instance.
190204
191205
```yaml
192-
Type: System.String
206+
Type: String
193207
Parameter Sets: (All)
194208
Aliases:
195209

@@ -201,14 +215,14 @@ Accept wildcard characters: False
201215
```
202216
203217
### -SoftDeleteRetentionInDays
204-
Specifies how long the deleted managed hsm pool is retained, and how long until the managed hsm pool in the deleted state can be purged. The default is 90 days.
218+
Specifies how long the deleted managed hsm pool is retained, and how long until the managed hsm pool in the deleted state can be purged.
205219
206220
```yaml
207-
Type: System.Int32
221+
Type: Int32
208222
Parameter Sets: (All)
209223
Aliases:
210224

211-
Required: False
225+
Required: True
212226
Position: Named
213227
Default value: None
214228
Accept pipeline input: False
@@ -221,7 +235,7 @@ By default, cmdlets are executed in the subscription that is set in the current
221235
Overriding subscriptions only take effect during the lifecycle of the current cmdlet. It does not change the subscription in the context, and does not affect subsequent cmdlets.
222236
223237
```yaml
224-
Type: System.String
238+
Type: String
225239
Parameter Sets: (All)
226240
Aliases:
227241

@@ -236,7 +250,7 @@ Accept wildcard characters: False
236250
A hash table which represents resource tags.
237251
238252
```yaml
239-
Type: System.Collections.Hashtable
253+
Type: Hashtable
240254
Parameter Sets: (All)
241255
Aliases: Tags
242256

@@ -247,27 +261,12 @@ Accept pipeline input: True (ByPropertyName)
247261
Accept wildcard characters: False
248262
```
249263
250-
### -Confirm
251-
Prompts you for confirmation before running the cmdlet.
252-
253-
```yaml
254-
Type: System.Management.Automation.SwitchParameter
255-
Parameter Sets: (All)
256-
Aliases: cf
257-
258-
Required: False
259-
Position: Named
260-
Default value: None
261-
Accept pipeline input: False
262-
Accept wildcard characters: False
263-
```
264-
265264
### -WhatIf
266265
Shows what would happen if the cmdlet runs.
267266
The cmdlet is not run.
268267
269268
```yaml
270-
Type: System.Management.Automation.SwitchParameter
269+
Type: SwitchParameter
271270
Parameter Sets: (All)
272271
Aliases: wi
273272

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"Module","ClassName","Target","Severity","ProblemId","Description","Remediation"
22
"Az.KeyVault","Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultCertificateContact","Add-AzKeyVaultCertificateContact","0","3010","The property 'IpRules' of type 'Microsoft.Azure.Management.KeyVault.Models.NetworkRuleSet' has been removed.","Add the property 'IpRules' back to type 'Microsoft.Azure.Management.KeyVault.Models.NetworkRuleSet'."
33
"Az.KeyVault","Microsoft.Azure.Commands.KeyVault.AddAzureKeyVaultKey","Add-AzKeyVaultKey","0","3010","The property 'IpRules' of type 'Microsoft.Azure.Management.KeyVault.Models.MhsmNetworkRuleSet' has been removed.","Add the property 'IpRules' back to type 'Microsoft.Azure.Management.KeyVault.Models.MhsmNetworkRuleSet'."
4-
"Az.KeyVault","Microsoft.Azure.Commands.KeyVault.SecurityDomain.Cmdlets.RestoreSecurityDomain","Import-AzKeyVaultSecurityDomain","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Import-AzKeyVaultSecurityDomain' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Import-AzKeyVaultSecurityDomain'."
4+
"Az.KeyVault","Microsoft.Azure.Commands.KeyVault.SecurityDomain.Cmdlets.RestoreSecurityDomain","Import-AzKeyVaultSecurityDomain","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Import-AzKeyVaultSecurityDomain' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Import-AzKeyVaultSecurityDomain'."
5+
"Az.KeyVault","Microsoft.Azure.Commands.KeyVault.Commands.NewAzureManagedHsm","New-AzKeyVaultManagedHsm","0","1050","The parameter set '__AllParameterSets' for cmdlet 'New-AzKeyVaultManagedHsm' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'New-AzKeyVaultManagedHsm'."

0 commit comments

Comments
 (0)