Home > Back-end >  Validate Azure Bicep string variable's length before deployment
Validate Azure Bicep string variable's length before deployment

Time:09-23

Similar to how a Bicep Module input parameter can be validated (e.g. allowed string length), is it possible to validate a string variable's length?

param input1 string
param input2 string

var combo = '${input1}${input2}' 

// Validate length of 'combo' to be below or equal to 64 characters here 

The reason is that I want to be able to catch resource deployment names that are too long (over 64 characters) during pre-flight validation.

CodePudding user response:

Not sure it is possible for variables but you could always define combo as a parameter and add a maxLength decorator:

param input1 string
param input2 string

@maxLength(64)
param combo string = '${input1}${input2}' 
  • Related