Updated on 2022-09-22 GMT+08:00

Expressions

value and pattern can be a constant or an expression. An expression is contained in ${}. You can use the following functions in the expression.

Table 1 String functions

Function

Parameter

Returned Value

Description

base64()

string

string

Encodes a specific string using Base64.

base64ToString()

string

string

Decodes a Base64-encoded string.

concat()

string, string

string

Concatenates two strings.

contains()

string, string

bool

Determines whether parameter 2 is a substring of parameter 1.

empty()

string

bool

Determines whether a string is left blank.

endsWith()

string, string

bool

Determines whether parameter 1 ends with parameter 2.

indexOf()

string, string

int

Returns the position of parameter 2 when it appears for the first time in parameter 1. If parameter 2 does not appear, -1 is returned.

lastIndexOf()

string, string

int

Returns the position of parameter 2 when it appears for the last time in parameter 1. If parameter 2 does not appear, -1 is returned.

length()

string

int

Returns the length of a string.

replace()

string, string, string

string

Replaces parameter 2 in parameter 1 with parameter 3.

startsWith()

string, string

bool

Determines whether parameter 1 starts with parameter 2.

toLower()

string

string

Converts all letters in a string into lowercase letters.

toUpper()

string

string

Converts all letters in a string into uppercase letters.

equals()

string, string

bool

Checks whether two strings are the same.

greater()

string, string

bool

Determines whether parameter 1 is greater than parameter 2.

greaterOrEquals()

string, string

bool

Determines whether parameter 1 is greater than or equal to parameter 2.

less()

string, string

bool

Determines whether parameter 1 is smaller than parameter 2.

lessOrEquals()

string, string

bool

Determines whether parameter 1 is no more than parameter 2.

split()

string, string

array

Returns the result of separating parameter 1 by parameter 2.

substring()

string, int, int

string

Obtains the substring of parameter 1. The start position of the substring is determined by parameter 2 and the length is determined by parameter 3.

Table 2 Numeric functions

Function

Parameter

Returned Value

Description

add()

int, int

int

Adds two integers.

max()

int, int

int

Uses the greater of the two integers.

min()

int, int

int

Uses the smaller of the two integers.

sub()

int, int

int

Calculates the result of parameter 1 minus parameter 2.

equals()

int, int

bool

Determines whether two integers are the same.

greater()

int, int

bool

Determines whether parameter 1 is greater than parameter 2.

greaterOrEquals()

int, int

bool

Determines whether parameter 1 is greater than or equal to parameter 2.

less()

int, int

bool

Determines whether parameter 1 is smaller than parameter 2.

lessOrEquals()

int, int

bool

Determines whether parameter 1 is no more than parameter 2.

Table 3 Array functions

Function

Parameter

Returned Value

Description

concat()

array, array

array

Concatenates two arrays.

contains()

array, any

bool

Determines whether parameter 2 is in array parameter 1.

empty()

array

bool

Determines whether the array is left blank.

first()

array

any

Returns the first element in the array.

last()

array

any

Returns the last element in the array.

length()

array

int

Returns the number of elements in the array.

Table 4 Object functions

Function

Parameter

Returned Value

Description

contains()

object, string

bool

Determines whether parameter 1 contains key-value parameter 2.

getValue()

object, string

any

Obtains the value corresponding to the key-value parameter 2 in parameter 1.

empty()

object

bool

Determines whether the object is left blank.

length()

object

int

Returns the number of key-value pairs in the object.

Table 5 Logical functions

Function

Parameter

Returned Value

Description

if()

bool, any, any

any

Determines whether parameter 1 is true. If yes, parameter 2 is returned. If no, parameter 3 is returned.

and()

bool, bool

bool

Determines whether both parameter 1 and parameter 2 are true.

or()

bool, bool

bool

Determines whether at least one of parameter 1 and parameter 2 is true.

not()

bool

bool

Inverts the input Boolean value.

Table 6 Functions related to resource compliance

Function

Parameter

Returned Value

Description

resource()

None

object

Returns the structure of the current evaluated resource.

parameters()

string

any

Returns a parameter defined in the parameters section.

In addition to use function computing in expressions, you can use:

  • a dot (.) to access a field in an object, for example, resource().properties.metadata.systemEncrypted.
  • CASE WHEN statement
    CASE WHEN condition1 THEN value1
         WHEN condition2 THEN value2
         ...
         ELSE defaultValue END