【问题标题】:Validate Azure Bicep string variable's length before deployment在部署前验证 Azure Bicep 字符串变量的长度
【发布时间】:2022-09-23 03:37:13
【问题描述】:

类似于如何验证二头肌模块输入参数(例如允许的字符串长度),是否可以验证字符串变量的长度?

param input1 string
param input2 string

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

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

原因是我希望能够在飞行前验证期间捕获太长(超过 64 个字符)的资源部署名称。

    标签: azure azure-resource-manager azure-bicep


    【解决方案1】:

    不确定变量是否可行,但您始终可以将combo 定义为参数并添加maxLength decorator

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

    【讨论】:

      猜你喜欢
      • 2018-03-07
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多