你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Bicep 的数字函数

本文介绍用于处理整数的 Bicep 函数。

某些 Azure 资源管理器 JSON 数字函数将被替换为 Bicep 数字运算符

int

int(valueToConvert)

将指定的值转换为整数。

命名空间:sys

参数

参数 必需 类型 说明
valueToConvert 字符串或整数 要转换为整数的值。

返回值

转换后的值的整数。

示例

以下示例将用户提供的参数值转换为整数。

param stringToConvert string = '4'

output inResult int = int(stringToConvert)

上述示例中使用默认值的输出为:

名称 类型 Value
intResult int 4

max

max(arg1)

返回整数数组或逗号分隔的整数列表中的最大值。

命名空间:sys

参数

参数 必需 类型 说明
arg1 整数数组或逗号分隔的整数列表 要获取最大值的集合。

返回值

一个整数,表示集合中的最大值。

示例

以下示例演示如何对整数数组和整数列表使用 max:

param arrayToTest array = [
  0
  3
  2
  5
  4
]

output arrayOutPut int = max(arrayToTest)
output intOutput int = max(0,3,2,5,4)

上述示例中使用默认值的输出为:

名称 类型
arrayOutput int 5
intOutput int 5

min

min(arg1)

返回整数数组或逗号分隔的整数列表中的最小值。

命名空间:sys

参数

参数 必需 类型 说明
arg1 整数数组或逗号分隔的整数列表 要获取最小值的集合。

返回值

一个整数,表示集合中的最小值。

示例

以下示例演示如何对整数数组和整数列表使用 min:

param arrayToTest array = [
  0
  3
  2
  5
  4
]

output arrayOutPut int = min(arrayToTest)
output intOutput int = min(0,3,2,5,4)

上述示例中使用默认值的输出为:

名称 类型
arrayOutput int 0
intOutput int 0

后续步骤