azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

New-AzureKeyVaultCertificatePolicy no longer accepts $null for RenewAtNumberOfDaysBeforeExpiry parameter

Open minghan opened this issue 8 years ago • 4 comments

Hi,

There is a bug introduced with https://github.com/Azure/azure-powershell/commit/150e4457bf4a17140f08b741237ddd607e43c602#r29314311

Previously, RenewAtPercentageLifetime parameter in New-AzureKeyVaultCertificatePolicy cmdlet accepted $null. However, with the new [ValidateRange] change, $null is not accepted and there is no way to disable the renew-at-percentage-lifetime feature. This is a breaking API change for which no heads up was given. Is this a bug?

Thanks, Ming Han

minghan avatar Jun 11 '18 07:06 minghan

@minghan Sorry for the late reply. You should be able to get the same functionality by simply not passing in the -RenewAtPercentageLifetime parameter, as the default value is $null. New-AzureKeyVaultCertificatePolicy creates a in-memory object which will have all values that are not set default to "null", which will propagate up when passed into either Add-AzureKeyVaultCertificate or Set-AzureKeyVaultCertificatePolicy. Are you seeing different behavior?

maddieclayton avatar Jun 14 '18 22:06 maddieclayton

Hi Maddie, I know there is a work around to not pass in the parameter. However, this presents a breaking change to existing scripts. Why can't we support the old behavior? Like I mentioned, this is clearly a bug, not a feature. Thanks.

minghan avatar Jun 17 '18 08:06 minghan

@minghan The appropriate PowerShell way to write Sets/News is to not pass in any parameter you would like to be set to the default value - if fact, most parameters have the “validate not null” attribute to ensure that this behavior is enforced. So in this case, not passing the parameter is not a work around, but rather the correct PowerShell practice. In this case, the change was made during a breaking change release, where you should expect some failures in you scripts while upgrading. This change was made because using ValidateRange is strongly encouraged by the PowerShell team, and because using a ValidateRange will cause bad cmdlet calls to fail faster, overall improving experience working with the cmdlet.

maddieclayton avatar Jun 20 '18 07:06 maddieclayton

Closing as will not fix.

maddieclayton avatar Jun 20 '18 07:06 maddieclayton