Home > Blockchain >  @minLength & @maxLength for securestring are causing problems when running `New-AzResourceGroupDeplo
@minLength & @maxLength for securestring are causing problems when running `New-AzResourceGroupDeplo

Time:01-09

I'm receiving the following error message:

New-AzResourceGroupDeployment: Cannot validate argument on parameter 'adminPassword'. The ValidateLength attribute cannot be applied to a parameter that is not a string or string[] parameter. Make the parameter a string or string[] parameter.

This happens when I run a bicep template containing the following code:

@description('MyDescription')
@minLength(12)
@maxLength(123)
@secure()
param adminPassword string

I'm running New-AzResourceGroupDeployment and it prompts me for adminPassword. When I enter it in the command prompt (interactively), I receive the error. Yes, I'm entering more than 13 characters in my password.

Removing @minLength and @maxLength lines helps.

I see that there is a closed issue https://github.com/Azure/azure-powershell/issues/8770.

But what's the actual problem? Is this a bug in the bicep script? Or is this a problem in Azure PowerShell / Bicep?

PS Reproducible on Windows and macOS with https://github.com/joshua-a-lucas/BlueTeamLab

CodePudding user response:

Our product team confirmed that adding the character length limit to secure string in bicep is not supported as of now and they are working on a fix for this you can refer to this git hub issue for the status on fix.

Character length limitation to secure string is supported in ARM templates.

  • Related