有关在 Azure 逻辑应用和 Power Automate 的表达式中使用函数的参考指南Reference guide to using functions in expressions for Azure Logic Apps and Power Automate

对于 Azure 逻辑应用Power Automate 中的工作流定义,某些表达式获取的值来自运行时操作,而这些运行时操作在工作流开始运行时可能尚不存在。For workflow definitions in Azure Logic Apps and Power Automate, some expressions get their values from runtime actions that might not yet exist when your workflow starts running. 若要引用这些值或处理这些表达式中的值,可以使用工作流定义语言提供的函数。To reference these values or process the values in these expressions, you can use functions provided by the Workflow Definition Language.

备注

本参考页适用于 Azure 逻辑应用和 Power Automate,但显示在 Azure 逻辑应用文档中。This reference page applies to both Azure Logic Apps and Power Automate, but appears in the Azure Logic Apps documentation. 虽然此页面提供的是逻辑应用的相关参考,但这些函数也适用于流应用。Although this page refers specifically to logic apps, these functions work for both flows and logic apps. 有关 Power Automate 中的函数和表达式的详细信息,请参阅在条件中使用表达式For more information about functions and expressions in Power Automate, see Use expressions in conditions.

例如,如果想要对整数或浮点数进行求和,可以使用数学函数(如 add() 函数)来计算值。For example, you can calculate values by using math functions, such as the add() function, when you want the sum from integers or floats. 下面是可以使用函数执行的一些其他示例任务:Here are other example tasks that you can perform with functions:

任务Task 函数语法Function syntax 结果Result
返回小写格式的字符串。Return a string in lowercase format. toLower('<text>')toLower('<text>')

例如:toLower('Hello')For example: toLower('Hello')

"hello""hello"
返回全局唯一标识符 (GUID)。Return a globally unique identifier (GUID). guid()guid() "c2ecc88d-88c8-4096-912c-d6f2e2b138ce""c2ecc88d-88c8-4096-912c-d6f2e2b138ce"

若要基于函数的常规用途查找函数,请查看以下各表。To find functions based on their general purpose, review the following tables. 若要了解每个函数的详细信息,请参阅按字母顺序排序的列表Or, for detailed information about each function, see the alphabetical list.

表达式中的函数Functions in expressions

为了展示如何在表达式中使用函数,此示例展示了如何从 customerName 参数获取值,并在表达式中使用 parameters() 函数将该值赋给 accountName 属性:To show how to use a function in an expression, this example shows how you can get the value from the customerName parameter and assign that value to the accountName property by using the parameters() function in an expression:

"accountName": "@parameters('customerName')"

下面是表达式中的函数的其他一般使用方法:Here are some other general ways that you can use functions in expressions:

任务Task 表达式中的函数语法Function syntax in an expression
通过将某个项传递给函数,对该项执行操作。Perform work with an item by passing that item to a function. "@<functionName>(<item>)""@<functionName>(<item>)"
1.使用嵌套的 parameters() 函数获取 parameterName 的值。1. Get the parameterName's value by using the nested parameters() function.
2.通过将结果传递给 functionName,对该值执行操作。2. Perform work with the result by passing that value to functionName.
"@<functionName>(parameters('<parameterName>'))""@<functionName>(parameters('<parameterName>'))"
1.从嵌套的内部函数 functionName 获取结果。1. Get the result from the nested inner function functionName.
2.将结果传递给外部函数 functionName22. Pass the result to the outer function functionName2.
"@<functionName2>(<functionName>(<item>))""@<functionName2>(<functionName>(<item>))"
1.从 functionName 获取结果。1. Get the result from functionName.
2.如果结果是包含属性 propertyName 的对象,则获取该属性的值。2. Given that the result is an object with property propertyName, get that property's value.
"@<functionName>(<item>).<propertyName>""@<functionName>(<item>).<propertyName>"

例如,concat() 函数可以采用两个或更多个字符串值作为参数。For example, the concat() function can take two or more string values as parameters. 此函数将这些字符串组合成一个字符串。This function combines those strings into one string. 可以传入字符串文字(例如 "Sophia" 和 "Owen"),以便获取组合的字符串 "SophiaOwen":You can either pass in string literals, for example, "Sophia" and "Owen" so that you get a combined string, "SophiaOwen":

"customerName": "@concat('Sophia', 'Owen')"

或者,可以从参数获取字符串值。Or, you can get string values from parameters. 此示例在每个 concat() 参数以及 firstNamelastName 参数中使用 parameters() 函数。This example uses the parameters() function in each concat() parameter and the firstName and lastName parameters. 然后,将生成的字符串传递给 concat() 函数,以便获取组合的字符串,例如 "SophiaOwen":You then pass the resulting strings to the concat() function so that you get a combined string, for example, "SophiaOwen":

"customerName": "@concat(parameters('firstName'), parameters('lastName'))"

无论使用哪种方式,这两个示例都会将结果分配给 customerName 属性。Either way, both examples assign the result to the customerName property.

下面是有关表达式中的函数的一些其他说明:Here are some other notes about functions in expressions:

  • 从左到右评估函数参数。Function parameters are evaluated from left to right.

  • 在参数定义的语法中,参数后显示的问号 (?) 表示参数是可选的。In the syntax for parameter definitions, a question mark (?) that appears after a parameter means the parameter is optional. 有关示例,请参阅 getFutureTime()For example, see getFutureTime().

以下各部分根据函数的常规用途来划分和组织函数,也可以按字母顺序浏览这些函数。The following sections organize functions based on their general purpose, or you can browse these functions in alphabetical order.

字符串函数String functions

若要使用字符串,可以使用这些字符串函数以及某些集合函数To work with strings, you can use these string functions and also some collection functions. 字符串函数仅适用于字符串。String functions work only on strings.

字符串函数String function 任务Task
concatconcat 组合两个或更多字符串,并返回组合后的字符串。Combine two or more strings, and return the combined string.
endsWithendsWith 检查字符串是否以指定的子字符串结尾。Check whether a string ends with the specified substring.
formatNumberformatNumber 根据指定的格式以字符串形式返回一个数字Return a number as a string based on the specified format
guidguid 生成字符串形式的全局唯一标识符 (GUID)。Generate a globally unique identifier (GUID) as a string.
indexOfindexOf 返回子字符串的起始位置。Return the starting position for a substring.
lastIndexOflastIndexOf 返回最后一次出现的子字符串的起始位置。Return the starting position for the last occurrence of a substring.
replacereplace 将子字符串替换为指定的字符串,并返回更新的字符串。Replace a substring with the specified string, and return the updated string.
splitsplit 根据原始字符串中指定的分隔符字符,从较大字符串中返回一个包含子字符串(以逗号分隔)的数组。Return an array that contains substrings, separated by commas, from a larger string based on a specified delimiter character in the original string.
startsWithstartsWith 检查字符串是否以特定的子字符串开头。Check whether a string starts with a specific substring.
substringsubstring 返回字符串中的字符,从指定的位置开始。Return characters from a string, starting from the specified position.
toLowertoLower 返回小写格式的字符串。Return a string in lowercase format.
toUppertoUpper 返回大写格式的字符串。Return a string in uppercase format.
trimtrim 从字符串中删除前导和尾随空格,并返回更新后的字符串。Remove leading and trailing whitespace from a string, and return the updated string.

集合函数Collection functions

若要使用集合(通常是数组或字符串,有时是字典),可以使用这些集合函数。To work with collections, generally arrays, strings, and sometimes, dictionaries, you can use these collection functions.

集合函数Collection function 任务Task
containscontains 检查集合是否包含某个特定项。Check whether a collection has a specific item.
emptyempty 检查集合是否为空。Check whether a collection is empty.
firstfirst 返回集合中的第一个项。Return the first item from a collection.
intersectionintersection 返回其中仅包含指定集合的共有项的一个集合。Return a collection that has only the common items across the specified collections.
itemitem 位于针对数组的重复操作中时,返回在操作的当前迭代过程中数组中的当前项。When inside a repeating action over an array, return the current item in the array during the action's current iteration.
joinjoin 返回一个字符串,其中包含某个数组中的所有项并以指定的分隔符分隔每个项。Return a string that has all the items from an array, separated by the specified character.
lastlast 返回集合中的最后一个项。Return the last item from a collection.
lengthlength 返回字符串或数组中的项数。Return the number of items in a string or array.
skipskip 删除集合开头的项,并返回所有其他项。Remove items from the front of a collection, and return all the other items.
taketake 返回集合开头的项。Return items from the front of a collection.
unionunion 返回一个集合,其中包含指定集合中的所有项。Return a collection that has all the items from the specified collections.

逻辑比较函数Logical comparison functions

若要使用条件、比较值和表达式结果或评估各种类型的逻辑,可以使用这些逻辑比较函数。To work with conditions, compare values and expression results, or evaluate various kinds of logic, you can use these logical comparison functions. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

备注

如果使用逻辑函数或条件来比较值,则 NULL 值将转换为空字符串 ("") 值。If you use logical functions or conditions to compare values, null values are converted to empty string ("") values. 与空字符串(而不是 NULL 值)进行比较时,条件的行为会有所不同。The behavior of conditions differs when you compare with an empty string instead of a null value. 有关详细信息,请参阅 string() 函数For more information, see the string() function.

逻辑比较函数Logical comparison function 任务Task
andand 检查所有表达式是否为 true。Check whether all expressions are true.
equalsequals 检查两个值是否相等。Check whether both values are equivalent.
greatergreater 检查第一个值是否大于第二个值。Check whether the first value is greater than the second value.
greaterOrEqualsgreaterOrEquals 检查第一个值是否大于或等于第二个值。Check whether the first value is greater than or equal to the second value.
ifif 检查表达式为 true 还是 false。Check whether an expression is true or false. 根据结果返回指定的值。Based on the result, return a specified value.
lessless 检查第一个值是否小于第二个值。Check whether the first value is less than the second value.
lessOrEqualslessOrEquals 检查第一个值是否小于或等于第二个值。Check whether the first value is less than or equal to the second value.
notnot 检查表达式是否为 false。Check whether an expression is false.
oror 检查是否至少一个表达式为 true。Check whether at least one expression is true.

转换函数Conversion functions

若要更改值的类型或格式,可以使用这些转换函数。To change a value's type or format, you can use these conversion functions. 例如,可将值从布尔值更改为整数。For example, you can change a value from a Boolean to an integer. 若要详细了解逻辑应用在转换期间如何处理内容类型,请参阅处理内容类型For more information about how Logic Apps handles content types during conversion, see Handle content types. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

备注

Azure 逻辑应用会自动在某些数据类型之间转换值,这意味着无需手动执行这些转换。Azure Logic Apps automatically converts values between some data types, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

转换函数Conversion function 任务Task
arrayarray 从单个指定的输入返回数组。Return an array from a single specified input. 对于多个输入,请参阅 createArrayFor multiple inputs, see createArray.
base64base64 返回字符串的 base64 编码版本。Return the base64-encoded version for a string.
base64ToBinarybase64ToBinary 返回 base64 编码字符串的二进制版本。Return the binary version for a base64-encoded string.
base64ToStringbase64ToString 返回 base64 编码字符串的字符串版本。Return the string version for a base64-encoded string.
binarybinary 返回输入值的二进制版本。Return the binary version for an input value.
boolbool 返回输入值的布尔值版本。Return the Boolean version for an input value.
createArraycreateArray 从多个输入返回数组。Return an array from multiple inputs.
dataUridataUri 返回输入值的数据 URI。Return the data URI for an input value.
dataUriToBinarydataUriToBinary 返回数据 URI 的二进制版本。Return the binary version for a data URI.
dataUriToStringdataUriToString 返回数据 URI 的字符串版本。Return the string version for a data URI.
decodeBase64decodeBase64 返回 base64 编码字符串的字符串版本。Return the string version for a base64-encoded string.
decodeDataUridecodeDataUri 返回数据 URI 的二进制版本。Return the binary version for a data URI.
decodeUriComponentdecodeUriComponent 返回一个字符串,并将其中的转义字符替换为解码后的版本。Return a string that replaces escape characters with decoded versions.
encodeUriComponentencodeUriComponent 返回一个字符串,并将其中的 URL 不安全字符替换为转义字符。Return a string that replaces URL-unsafe characters with escape characters.
floatfloat 返回输入值的浮点数。Return a floating point number for an input value.
intint 返回字符串的整数版本。Return the integer version for a string.
jsonjson 返回字符串或 XML 的 JavaScript 对象表示法 (JSON) 类型的值或对象。Return the JavaScript Object Notation (JSON) type value or object for a string or XML.
stringstring 返回输入值的字符串版本。Return the string version for an input value.
uriComponenturiComponent 通过将 URL 不安全字符替换为转义字符来返回输入值的 URI 编码版本。Return the URI-encoded version for an input value by replacing URL-unsafe characters with escape characters.
uriComponentToBinaryuriComponentToBinary 返回 URI 编码字符串的二进制版本。Return the binary version for a URI-encoded string.
uriComponentToStringuriComponentToString 返回 URI 编码字符串的字符串版本。Return the string version for a URI-encoded string.
xmlxml 返回字符串的 XML 版本。Return the XML version for a string.

隐式数据类型转换Implicit data type conversions

Azure 逻辑应用会自动或隐式地在某些数据类型之间进行转换,因此无需手动转换这些类型。Azure Logic Apps automatically or implicitly converts between some data types, so you don't have to manually convert these types. 例如,如果在预期应输入字符串的情况下输入了非字符串值,则逻辑应用会自动将非字符串值转换为字符串。For example, if you use non-string values where strings are expected as inputs, Logic Apps automatically converts the non-string values into strings.

例如,假设触发器返回一个数值作为输出:For example, suppose a trigger returns a numerical value as output:

triggerBody()?['123']

如果在需要字符串作为输入(如 URL)的地方使用了此数值输出值,则逻辑应用会使用大括号 ({}) 表示法自动将该值转换为字符串:If you use this numerical output where string input is expected, such as a URL, Logic Apps automatically converts the value into a string by using the curly braces ({}) notation:

@{triggerBody()?['123']}

Base64 编码和解码Base64 encoding and decoding

逻辑应用会自动或隐式执行 base64 编码或解码,因此无需使用相应的表达式手动执行这些操作:Logic Apps automatically or implicitly performs base64 encoding or decoding, so you don't have to manually perform these operations by using the corresponding expressions:

  • base64(<value>)
  • base64ToBinary(<value>)
  • base64ToString(<value>)
  • base64(decodeDataUri(<value>))
  • concat('data:;base64,',<value>)
  • concat('data:,',encodeUriComponent(<value>))
  • decodeDataUri(<value>)

备注

如果手动将这些表达式添加到逻辑应用(比如使用表达式编辑器),那么如果离开逻辑应用设计器,然后再返回设计器,设计器只会显示参数值。If you manually add these expressions to your logic app, for example, by using the expression editor, navigate away from the Logic App Designer and return to the designer, the designer shows only the parameter values. 仅当未编辑参数值时,表达式才会保留在代码视图中。The expressions are preserved in code view only if you don't edit the parameter values. 否则,逻辑应用会从代码视图中删除表达式,而仅保留参数值。Otherwise, Logic Apps removes the expressions from code view, leaving only the parameter values. 此行为不会影响编码或解码,而只会影响表达式的显示与否。This behavior doesn't affect encoding or decoding, only whether the expressions are shown.

数学函数Math functions

若要使用整数和浮点数,可以使用这些数学函数。To work with integers and floats, you can use these math functions. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

数学函数Math function 任务Task
addadd 返回两个数字相加的结果。Return the result from adding two numbers.
divdiv 返回两个数字相除的结果。Return the result from dividing two numbers.
maxmax 返回一组数字或数组中的最大值。Return the highest value from a set of numbers or an array.
minmin 返回一组数字或数组中的最小值。Return the lowest value from a set of numbers or an array.
modmod 返回将两个数字相除后的余数。Return the remainder from dividing two numbers.
mulmul 返回将两个数字相乘得到的乘积。Return the product from multiplying two numbers.
randrand 返回指定范围内的随机整数。Return a random integer from a specified range.
rangerange 返回以指定整数开头的一个整数数组。Return an integer array that starts from a specified integer.
subsub 返回第一个数字减去第二个数字得到的结果。Return the result from subtracting the second number from the first number.

日期和时间函数Date and time functions

若要使用日期和时间,可以使用这些日期和时间函数。To work with dates and times, you can use these date and time functions. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

日期或时间函数Date or time function 任务Task
addDaysaddDays 将天数加到时间戳。Add a number of days to a timestamp.
addHoursaddHours 将小时数加到时间戳。Add a number of hours to a timestamp.
addMinutesaddMinutes 将分钟数加到时间戳。Add a number of minutes to a timestamp.
addSecondsaddSeconds 将秒数加到时间戳。Add a number of seconds to a timestamp.
addToTimeaddToTime 将一定数目的时间单位加到时间戳。Add a number of time units to a timestamp. 另请参阅 getFutureTimeSee also getFutureTime.
convertFromUtcconvertFromUtc 将时间戳从协调世界时 (UTC) 转换为目标时区。Convert a timestamp from Universal Time Coordinated (UTC) to the target time zone.
convertTimeZoneconvertTimeZone 将时间戳从源时区转换为目标时区。Convert a timestamp from the source time zone to the target time zone.
convertToUtcconvertToUtc 将时间戳从源时区转换为协调世界时 (UTC)。Convert a timestamp from the source time zone to Universal Time Coordinated (UTC).
dayOfMonthdayOfMonth 返回时间戳中月份组成部分的日期。Return the day of the month component from a timestamp.
dayOfWeekdayOfWeek 返回时间戳中周组成部分的星期日期。Return the day of the week component from a timestamp.
dayOfYeardayOfYear 返回时间戳中年组成部分的日期。Return the day of the year component from a timestamp.
formatDateTimeformatDateTime 返回时间戳中的日期。Return the date from a timestamp.
getFutureTimegetFutureTime 返回当前时间戳加上指定的时间单位。Return the current timestamp plus the specified time units. 另请参阅 addToTimeSee also addToTime.
getPastTimegetPastTime 返回当前时间戳减去指定的时间单位。Return the current timestamp minus the specified time units. 另请参阅 subtractFromTimeSee also subtractFromTime.
startOfDaystartOfDay 返回时间戳中的天的开始时间。Return the start of the day for a timestamp.
startOfHourstartOfHour 返回时间戳中的小时的开始时间。Return the start of the hour for a timestamp.
startOfMonthstartOfMonth 返回时间戳中的月份的开始时间。Return the start of the month for a timestamp.
subtractFromTimesubtractFromTime 从时间戳中减去一定数目的时间单位。Subtract a number of time units from a timestamp. 另请参阅 getPastTimeSee also getPastTime.
ticksticks 返回指定时间戳的 ticks 属性值。Return the ticks property value for a specified timestamp.
utcNowutcNow 返回字符串形式的当前时间戳。Return the current timestamp as a string.

工作流函数Workflow functions

这些工作流函数有助于:These workflow functions can help you:

  • 在运行时获取有关工作流实例的详细信息。Get details about a workflow instance at run time.
  • 使用用于实例化逻辑应用或流的输入。Work with the inputs used for instantiating logic apps or flows.
  • 引用触发器和操作的输出。Reference the outputs from triggers and actions.

例如,可以引用一个操作的输出,并在后面的操作中使用该数据。For example, you can reference the outputs from one action and use that data in a later action. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

工作流函数Workflow function 任务Task
actionaction 返回当前操作在运行时的输出,或者来自其他 JSON 名称和值对的值。Return the current action's output at runtime, or values from other JSON name-and-value pairs. 另请参阅 actionsSee also actions.
actionBodyactionBody 返回操作在运行时的 body 输出。Return an action's body output at runtime. 另请参阅 bodySee also body.
actionOutputsactionOutputs 返回操作在运行时的输出。Return an action's output at runtime. 请参阅输出操作See outputs and actions.
actionsactions 返回操作在运行时的输出,或者来自其他 JSON 名称和值对的值。Return an action's output at runtime, or values from other JSON name-and-value pairs. 另请参阅 actionSee also action.
bodybody 返回操作在运行时的 body 输出。Return an action's body output at runtime. 另请参阅 actionBodySee also actionBody.
formDataMultiValuesformDataMultiValues 创建一个数组,其中包含与表单数据或表单编码操作输出中某个键名匹配的值。 Create an array with the values that match a key name in form-data or form-encoded action outputs.
formDataValueformDataValue 返回与操作的表单数据或表单编码输出中的键名称匹配的单个值。 Return a single value that matches a key name in an action's form-data or form-encoded output.
itemitem 位于针对数组的重复操作中时,返回在操作的当前迭代过程中数组中的当前项。When inside a repeating action over an array, return the current item in the array during the action's current iteration.
itemsitems 位于 Foreach 或 Until 循环中时,返回指定循环中的当前项。When inside a Foreach or Until loop, return the current item from the specified loop.
iterationIndexesiterationIndexes 位于 Until 循环中时,返回当前迭代的索引值。When inside an Until loop, return the index value for the current iteration. 可以在嵌套式的 Until 循环中使用该函数。You can use this function inside nested Until loops.
listCallbackUrllistCallbackUrl 返回调用某个触发器或操作的“回调 URL”。Return the "callback URL" that calls a trigger or action.
multipartBodymultipartBody 返回具有多个部分的操作输出中某个特定部分的正文。Return the body for a specific part in an action's output that has multiple parts.
outputsoutputs 返回操作在运行时的输出。Return an action's output at runtime.
parametersparameters 返回工作流定义中描述的参数的值。Return the value for a parameter that is described in your workflow definition.
resultresult 返回指定的范围受限操作(例如 For_eachUntilScope)中所有操作的输入和输出。Return the inputs and outputs from all the actions inside the specified scoped action, such as For_each, Until, and Scope.
triggertrigger 返回触发器在运行时的输出,或者来自其他 JSON 名称和值对的输出。Return a trigger's output at runtime, or from other JSON name-and-value pairs. 另请参阅 triggerOutputstriggerBodySee also triggerOutputs and triggerBody.
triggerBodytriggerBody 返回触发器在运行时的 body 输出。Return a trigger's body output at runtime. 请参阅 triggerSee trigger.
triggerFormDataValuetriggerFormDataValue 返回与表单数据或表单编码触发器输出中某个键名匹配的单个值。 Return a single value matching a key name in form-data or form-encoded trigger outputs.
triggerMultipartBodytriggerMultipartBody 返回触发器多部分输出中特定部分的正文。Return the body for a specific part in a trigger's multipart output.
triggerFormDataMultiValuestriggerFormDataMultiValues 创建一个数组,该数组的值与表单数据或表单编码触发器输出中某个键名匹配。 Create an array whose values match a key name in form-data or form-encoded trigger outputs.
triggerOutputstriggerOutputs 返回触发器在运行时的输出,或者来自其他 JSON 名称和值对的值。Return a trigger's output at runtime, or values from other JSON name-and-value pairs. 请参阅 triggerSee trigger.
variablesvariables 返回指定变量的值。Return the value for a specified variable.
workflowworkflow 返回运行期间有关工作流本身的所有详细信息。Return all the details about the workflow itself during run time.

URI 分析函数URI parsing functions

若要使用统一资源标识符 (URI) 并获取这些 URI 的各个属性值,可以使用这些 URI 分析函数。To work with uniform resource identifiers (URIs) and get various property values for these URIs, you can use these URI parsing functions. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

URI 分析函数URI parsing function 任务Task
uriHosturiHost 返回统一资源标识符 (URI) 的 host 值。Return the host value for a uniform resource identifier (URI).
uriPathuriPath 返回统一资源标识符 (URI) 的 path 值。Return the path value for a uniform resource identifier (URI).
uriPathAndQueryuriPathAndQuery 返回统一资源标识符 (URI) 的 pathquery 值。Return the path and query values for a uniform resource identifier (URI).
uriPorturiPort 返回统一资源标识符 (URI) 的 port 值。Return the port value for a uniform resource identifier (URI).
uriQueryuriQuery 返回统一资源标识符 (URI) 的 query 值。Return the query value for a uniform resource identifier (URI).
uriSchemeuriScheme 返回统一资源标识符 (URI) 的 scheme 值。Return the scheme value for a uniform resource identifier (URI).

操作函数:JSON 和 XMLManipulation functions: JSON & XML

若要使用 JSON 对象和 XML 节点,可以使用这些操作函数。To work with JSON objects and XML nodes, you can use these manipulation functions. 有关每个函数的完整参考,请参阅按字母顺序排序的列表For the full reference about each function, see the alphabetical list.

操作函数Manipulation function 任务Task
addPropertyaddProperty 将属性及其值或名称/值对添加到 JSON 对象,并返回更新的对象。Add a property and its value, or name-value pair, to a JSON object, and return the updated object.
coalescecoalesce 返回一个或多个参数中的第一个非 null 值。Return the first non-null value from one or more parameters.
removePropertyremoveProperty 从 JSON 对象中删除某个属性,并返回更新的对象。Remove a property from a JSON object and return the updated object.
setPropertysetProperty 设置 JSON 对象的属性值并返回更新的对象。Set the value for a JSON object's property and return the updated object.
xpathxpath 检查 XML 中是否存在与 XPath(XML 路径语言)表达式匹配的节点或值,并返回匹配的节点或值。Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values.

所有函数 - 字母列表All functions - alphabetical list

此部分按字母顺序列出所有可用函数。This section lists all the available functions in alphabetical order.

actionaction

返回“当前”操作在运行时的输出,或者来自其他 JSON 名称和值对的值,可以将其分配给表达式。Return the current action's output at runtime, or values from other JSON name-and-value pairs, which you can assign to an expression. 默认情况下,此函数引用整个操作对象,但是也可以指定你需要其值的属性。By default, this function references the entire action object, but you can optionally specify a property whose value you want. 另请参阅 actions()See also actions().

只能在以下位置使用 action() 函数:You can use the action() function only in these places:

  • Webhook 操作的 unsubscribe 属性,用以访问原始 subscribe 请求的结果The unsubscribe property for a webhook action so you can access the result from the original subscribe request
  • 操作的 trackedProperties 属性The trackedProperties property for an action
  • 操作的 do-until 循环条件The do-until loop condition for an action
action()
action().outputs.body.<property>
参数Parameter 必须Required 类型Type 说明Description
<property><property> No StringString 需要获取其值的操作对象属性的名称:namestartTimeendTimeinputsoutputsstatuscodetrackingIdclientTrackingIdThe name for the action object's property whose value you want: name, startTime, endTime, inputs, outputs, status, code, trackingId, and clientTrackingId. 在 Azure 门户中,可以通过查看特定运行历史记录的详细信息来查找这些属性。In the Azure portal, you can find these properties by reviewing a specific run history's details. 有关详细信息,请参阅 REST API - 工作流运行操作For more information, see REST API - Workflow Run Actions.
返回值Return value 类型Type 说明Description
<action-output><action-output> StringString 当前操作或属性的输出The output from the current action or property

actionBodyactionBody

返回操作在运行时的 body 输出。Return an action's body output at runtime. actions('<actionName>').outputs.body 的速记。Shorthand for actions('<actionName>').outputs.body. 请参阅 body()actions()See body() and actions().

actionBody('<actionName>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 所需的操作 body 输出的名称The name for the action's body output that you want
返回值Return value 类型Type 说明Description
<action-body-output><action-body-output> StringString 指定操作的 body 输出The body output from the specified action

示例Example

此示例获取 Twitter 操作 Get userbody 输出:This example gets the body output from the Twitter action Get user:

actionBody('Get_user')

并返回以下结果:And returns this result:

"body": {
  "FullName": "Contoso Corporation",
  "Location": "Generic Town, USA",
  "Id": 283541717,
  "UserName": "ContosoInc",
  "FollowersCount": 172,
  "Description": "Leading the way in transforming the digital workplace.",
  "StatusesCount": 93,
  "FriendsCount": 126,
  "FavouritesCount": 46,
  "ProfileImageUrl": "https://pbs.twimg.com/profile_images/908820389907722240/gG9zaHcd_400x400.jpg"
}

actionOutputsactionOutputs

返回操作在运行时的输出。Return an action's output at runtime. actions('<actionName>').outputs 的速记。and is shorthand for actions('<actionName>').outputs. 请参阅 actions()See actions(). actionOutputs() 函数在逻辑应用设计器中解析为 outputs(),因此请考虑使用 outputs(),而不是 actionOutputs()The actionOutputs() function resolves to outputs() in the Logic App Designer, so consider using outputs(), rather than actionOutputs(). 虽然这两个函数的工作方式相同,但首选 outputs()Although both functions work the same way, outputs() is preferred.

actionOutputs('<actionName>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 所需的操作输出的名称The name for the action's output that you want
返回值Return value 类型Type 说明Description
<output><output> StringString 指定操作的输出The output from the specified action

示例Example

此示例获取 Twitter 操作 Get user 的输出:This example gets the output from the Twitter action Get user:

actionOutputs('Get_user')

并返回以下结果:And returns this result:

{
  "statusCode": 200,
  "headers": {
    "Pragma": "no-cache",
    "Vary": "Accept-Encoding",
    "x-ms-request-id": "a916ec8f52211265d98159adde2efe0b",
    "X-Content-Type-Options": "nosniff",
    "Timing-Allow-Origin": "*",
    "Cache-Control": "no-cache",
    "Date": "Mon, 09 Apr 2018 18:47:12 GMT",
    "Set-Cookie": "ARRAffinity=b9400932367ab5e3b6802e3d6158afffb12fcde8666715f5a5fbd4142d0f0b7d;Path=/;HttpOnly;Domain=twitter-wus.azconn-wus.p.chinacloudsites.cn",
    "X-AspNet-Version": "4.0.30319",
    "X-Powered-By": "ASP.NET",
    "Content-Type": "application/json; charset=utf-8",
    "Expires": "-1",
    "Content-Length": "339"
  },
  "body": {
    "FullName": "Contoso Corporation",
    "Location": "Generic Town, USA",
    "Id": 283541717,
    "UserName": "ContosoInc",
    "FollowersCount": 172,
    "Description": "Leading the way in transforming the digital workplace.",
    "StatusesCount": 93,
    "FriendsCount": 126,
    "FavouritesCount": 46,
    "ProfileImageUrl": "https://pbs.twimg.com/profile_images/908820389907722240/gG9zaHcd_400x400.jpg"
  }
}

actionsactions

返回操作在运行时的输出,或者来自其他 JSON 名称和值对的值,可以将其分配给表达式。Return an action's output at runtime, or values from other JSON name-and-value pairs, which you can assign to an expression. 默认情况下,此函数引用整个操作对象,但是也可以指定你需要其值的属性。By default, the function references the entire action object, but you can optionally specify a property whose value that you want. 有关速记版本,请参阅 actionBody()actionOutputs()body()For shorthand versions, see actionBody(), actionOutputs(), and body(). 有关当前操作,请参阅 action()For the current action, see action().

提示

actions() 函数以字符串的形式返回输出。The actions() function returns output as a string. 如果需要将返回值用作 JSON 对象,则首先需要转换字符串值。If you need to work with a returned value as a JSON object, you first need to convert the string value. 可以使用分析 JSON 操作将字符串值转换为 JSON 对象。You can transform the string value into a JSON object using the Parse JSON action.

备注

以前,当指定基于另一操作的输出运行的操作时,可以使用 actions() 函数或 conditions 元素。Previously, you could use the actions() function or the conditions element when specifying that an action ran based on the output from another action. 但是,若要显式声明操作之间的依赖关系,现在必须使用依赖的操作的 runAfter 属性。However, to declare explicitly dependencies between actions, you must now use the dependent action's runAfter property. 若要详细了解 runAfter 属性,请参阅使用 runAfter 属性捕获和处理故障To learn more about the runAfter property, see Catch and handle failures with the runAfter property.

actions('<actionName>')
actions('<actionName>').outputs.body.<property>
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 需要获取其输出的操作对象的名称The name for the action object whose output you want
<property><property> No StringString 需要获取其值的操作对象属性的名称:namestartTimeendTimeinputsoutputsstatuscodetrackingIdclientTrackingIdThe name for the action object's property whose value you want: name, startTime, endTime, inputs, outputs, status, code, trackingId, and clientTrackingId. 在 Azure 门户中,可以通过查看特定运行历史记录的详细信息来查找这些属性。In the Azure portal, you can find these properties by reviewing a specific run history's details. 有关详细信息,请参阅 REST API - 工作流运行操作For more information, see REST API - Workflow Run Actions.
返回值Return value 类型Type 说明Description
<action-output><action-output> StringString 指定操作或属性的输出The output from the specified action or property

示例Example

此示例获取 Twitter 操作 Get user 在运行时的 status 属性值:This example gets the status property value from the Twitter action Get user at runtime:

actions('Get_user').outputs.body.status

并返回以下结果:"Succeeded"And returns this result: "Succeeded"

addadd

返回两个数字相加的结果。Return the result from adding two numbers.

add(<summand_1>, <summand_2>)
参数Parameter 必须Required 类型Type 说明Description
<summand_1>, <summand_2><summand_1>, <summand_2> Yes 整数、浮点数或混合类型Integer, Float, or mixed 要相加的数字The numbers to add
返回值Return value 类型Type 说明Description
<result-sum><result-sum> 整数或浮点数Integer or Float 指定数字相加的结果。The result from adding the specified numbers

示例Example

此示例将指定的数字相加:This example adds the specified numbers:

add(1, 1.5)

并返回以下结果:2.5And returns this result: 2.5

addDaysaddDays

将天数加到时间戳。Add a number of days to a timestamp.

addDays('<timestamp>', <days>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<days><days> Yes IntegerInteger 要加上的正负天数The positive or negative number of days to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的天数The timestamp plus the specified number of days

示例 1Example 1

此示例将 10 天加到指定的时间戳:This example adds 10 days to the specified timestamp:

addDays('2018-03-15T13:00:00Z', 10)

并返回以下结果:"2018-03-25T00:00:0000000Z"And returns this result: "2018-03-25T00:00:0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 天:This example subtracts five days from the specified timestamp:

addDays('2018-03-15T00:00:00Z', -5)

并返回以下结果:"2018-03-10T00:00:0000000Z"And returns this result: "2018-03-10T00:00:0000000Z"

addHoursaddHours

将小时数加到时间戳。Add a number of hours to a timestamp.

addHours('<timestamp>', <hours>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<hours><hours> Yes IntegerInteger 要加上的正负小时数The positive or negative number of hours to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的小时数The timestamp plus the specified number of hours

示例 1Example 1

此示例将 10 小时加到指定的时间戳:This example adds 10 hours to the specified timestamp:

addHours('2018-03-15T00:00:00Z', 10)

并返回以下结果:"2018-03-15T10:00:0000000Z"And returns this result: "2018-03-15T10:00:0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 小时:This example subtracts five hours from the specified timestamp:

addHours('2018-03-15T15:00:00Z', -5)

并返回以下结果:"2018-03-15T10:00:0000000Z"And returns this result: "2018-03-15T10:00:0000000Z"

addMinutesaddMinutes

将分钟数加到时间戳。Add a number of minutes to a timestamp.

addMinutes('<timestamp>', <minutes>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<minutes><minutes> Yes IntegerInteger 要加上的正负分钟数The positive or negative number of minutes to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的分钟数The timestamp plus the specified number of minutes

示例 1Example 1

此示例将 10 分钟加到指定的时间戳:This example adds 10 minutes to the specified timestamp:

addMinutes('2018-03-15T00:10:00Z', 10)

并返回以下结果:"2018-03-15T00:20:00.0000000Z"And returns this result: "2018-03-15T00:20:00.0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 分钟:This example subtracts five minutes from the specified timestamp:

addMinutes('2018-03-15T00:20:00Z', -5)

并返回以下结果:"2018-03-15T00:15:00.0000000Z"And returns this result: "2018-03-15T00:15:00.0000000Z"

addPropertyaddProperty

将属性及其值或名称/值对添加到 JSON 对象,并返回更新的对象。Add a property and its value, or name-value pair, to a JSON object, and return the updated object. 如果在运行时已存在该属性,此函数会失败并引发错误。If the property already exists at runtime, the function fails and throws an error.

addProperty(<object>, '<property>', <value>)
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要将属性添加到的 JSON 对象The JSON object where you want to add a property
<property><property> Yes StringString 要添加的属性的名称The name for the property to add
<value><value> Yes 任意Any 属性的值The value for the property
返回值Return value 类型Type 说明Description
<updated-object><updated-object> ObjectObject 具有指定属性的更新后 JSON 对象The updated JSON object with the specified property

若要向现有属性添加子属性,请使用以下语法:To add a child property to an existing property, use this syntax:

addProperty(<object>['<parent-property>'], '<child-property>', <value>)
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要将属性添加到的 JSON 对象The JSON object where you want to add a property
<parent-property><parent-property> Yes StringString 要在其中添加子属性的父属性的名称The name for parent property where you want to add the child property
<child-property><child-property> Yes StringString 要添加的子属性的名称The name for the child property to add
<value><value> Yes 任意Any 要为指定属性设置的值The value to set for the specified property
返回值Return value 类型Type 说明Description
<updated-object><updated-object> ObjectObject 设置了其属性的更新后 JSON 对象The updated JSON object whose property you set

示例 1Example 1

此示例将 middleName 属性加到 JSON 对象,可通过 JSON() 函数将其从字符串转换为 JSON。This example adds the middleName property to a JSON object, which is converted from a string to JSON by using the JSON() function. 该对象已经包含 firstNamesurName 属性。The object already includes the firstName and surName properties. 该函数将指定的值分配给新属性,并返回更新后的对象:The function assigns the specified value to the new property and returns the updated object:

addProperty(json('{ "firstName": "Sophia", "lastName": "Owen" }'), 'middleName', 'Anne')

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "firstName": "Sophia",
   "surName": "Owen"
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "firstName": "Sophia",
   "middleName": "Anne",
   "surName": "Owen"
}

示例 2Example 2

此示例将 middleName 子属性加到 JSON 对象中的现有 customerName 属性,可通过 JSON() 函数将其从字符串转换为 JSON。This example adds the middleName child property to the existing customerName property in a JSON object, which is converted from a string to JSON by using the JSON() function. 该函数将指定的值分配给新属性,并返回更新后的对象:The function assigns the specified value to the new property and returns the updated object:

addProperty(json('{ "customerName": { "firstName": "Sophia", "surName": "Owen" } }')['customerName'], 'middleName', 'Anne')

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "customerName": {
      "firstName": "Sophia",
      "surName": "Owen"
   }
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "customerName": {
      "firstName": "Sophia",
      "middleName": "Anne",
      "surName": "Owen"
   }
}

addSecondsaddSeconds

将秒数加到时间戳。Add a number of seconds to a timestamp.

addSeconds('<timestamp>', <seconds>, '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<seconds><seconds> Yes IntegerInteger 要加上的正负秒数The positive or negative number of seconds to add
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的秒数The timestamp plus the specified number of seconds

示例 1Example 1

此示例将 10 秒加到指定的时间戳:This example adds 10 seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:00Z', 10)

并返回以下结果:"2018-03-15T00:00:10.0000000Z"And returns this result: "2018-03-15T00:00:10.0000000Z"

示例 2Example 2

此示例从指定的时间戳减去 5 秒:This example subtracts five seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:30Z', -5)

并返回以下结果:"2018-03-15T00:00:25.0000000Z"And returns this result: "2018-03-15T00:00:25.0000000Z"

addToTimeaddToTime

将一定数目的时间单位加到时间戳。Add a number of time units to a timestamp. 另请参阅 getFutureTime()See also getFutureTime().

addToTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<间隔><interval> Yes IntegerInteger 要添加的指定时间单位数The number of specified time units to add
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳加上指定的时间单位数The timestamp plus the specified number of time units

示例 1Example 1

此示例将 1 天加到指定的时间戳:This example adds one day to the specified timestamp:

addToTime('2018-01-01T00:00:00Z', 1, 'Day')

并返回以下结果:"2018-01-02T00:00:00.0000000Z"And returns this result: "2018-01-02T00:00:00.0000000Z"

示例 2Example 2

此示例将 1 天加到指定的时间戳:This example adds one day to the specified timestamp:

addToTime('2018-01-01T00:00:00Z', 1, 'Day', 'D')

并使用可选的“D”格式返回结果:"Tuesday, January 2, 2018"And returns the result using the optional "D" format: "Tuesday, January 2, 2018"

andand

检查所有表达式是否为 true。Check whether all expressions are true. 当所有表达式均为 true 时返回 true,当至少一个表达式为 false 时返回 false。Return true when all expressions are true, or return false when at least one expression is false.

and(<expression1>, <expression2>, ...)
参数Parameter 必须Required 类型Type 说明Description
<expression1>, <expression2>, ...<expression1>, <expression2>, ... Yes 布尔Boolean 要检查的表达式The expressions to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当所有表达式均为 true 时返回 true。Return true when all expressions are true. 当至少一个表达式为 false 时返回 false。Return false when at least one expression is false.

示例 1Example 1

这些示例检查指定的布尔值是否全为 true:These examples check whether the specified Boolean values are all true:

and(true, true)
and(false, true)
and(false, false)

并返回以下结果:And returns these results:

  • 第一个示例:两个表达式均为 true,因此返回 trueFirst example: Both expressions are true, so returns true.
  • 第二个示例:一个表达式为 false,因此返回 falseSecond example: One expression is false, so returns false.
  • 第三个示例:两个表达式均为 false,因此返回 falseThird example: Both expressions are false, so returns false.

示例 2Example 2

这些示例检查指定的表达式是否均为 true:These examples check whether the specified expressions are all true:

and(equals(1, 1), equals(2, 2))
and(equals(1, 1), equals(1, 2))
and(equals(1, 2), equals(1, 3))

并返回以下结果:And returns these results:

  • 第一个示例:两个表达式均为 true,因此返回 trueFirst example: Both expressions are true, so returns true.
  • 第二个示例:一个表达式为 false,因此返回 falseSecond example: One expression is false, so returns false.
  • 第三个示例:两个表达式均为 false,因此返回 falseThird example: Both expressions are false, so returns false.

arrayarray

从单个指定的输入返回数组。Return an array from a single specified input. 对于多个输入,请参阅 createArray()For multiple inputs, see createArray().

array('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 用于创建数组的字符串The string for creating an array
返回值Return value 类型Type 说明Description
[<value>][<value>] ArrayArray 一个包含单一指定输入的数组An array that contains the single specified input

示例Example

此示例基于“hello”字符串创建数组:This example creates an array from the "hello" string:

array('hello')

并返回以下结果:["hello"]And returns this result: ["hello"]

base64base64

返回字符串的 base64 编码版本。Return the base64-encoded version for a string.

备注

Azure 逻辑应用会自动执行 base64 编码和解码,这意味着无需手动执行这些转换。Azure Logic Apps automatically performs base64 encoding and decoding, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

base64('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 输入字符串The input string
返回值Return value 类型Type 说明Description
<base64-string><base64-string> StringString 返回输入字符串的 base64 编码版本The base64-encoded version for the input string

示例Example

此示例将“hello”字符串转换为 base64 编码的字符串:This example converts the "hello" string to a base64-encoded string:

base64('hello')

并返回以下结果:"aGVsbG8="And returns this result: "aGVsbG8="

base64ToBinarybase64ToBinary

返回 base64 编码字符串的二进制版本。Return the binary version for a base64-encoded string.

备注

Azure 逻辑应用会自动执行 base64 编码和解码,这意味着无需手动执行这些转换。Azure Logic Apps automatically performs base64 encoding and decoding, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

base64ToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的 base64 编码字符串The base64-encoded string to convert
返回值Return value 类型Type 说明Description
<binary-for-base64-string><binary-for-base64-string> StringString base64 编码字符串的二进制版本The binary version for the base64-encoded string

示例Example

此示例将 base64 编码的“aGVsbG8=”字符串转换为二进制字符串:This example converts the "aGVsbG8=" base64-encoded string to a binary string:

base64ToBinary('aGVsbG8=')

并返回以下结果:And returns this result:

"0110000101000111010101100111001101100010010001110011100000111101"

base64ToStringbase64ToString

返回 base64 编码字符串的字符串版本,有效地对 base64 字符串进行解码。Return the string version for a base64-encoded string, effectively decoding the base64 string. 使用此函数,而不是已弃用的 decodeBase64()Use this function rather than decodeBase64(), which is deprecated.

备注

Azure 逻辑应用会自动执行 base64 编码和解码,这意味着无需手动执行这些转换。Azure Logic Apps automatically performs base64 encoding and decoding, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

base64ToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的 base64 编码字符串The base64-encoded string to decode
返回值Return value 类型Type 说明Description
<decoded-base64-string><decoded-base64-string> StringString base64 编码字符串的字符串版本The string version for a base64-encoded string

示例Example

此示例将 base64 编码的“aGVsbG8=”字符串转换为单纯的字符串:This example converts the "aGVsbG8=" base64-encoded string to just a string:

base64ToString('aGVsbG8=')

并返回以下结果:"hello"And returns this result: "hello"

binarybinary

返回字符串的二进制版本。Return the binary version for a string.

binary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<binary-for-input-value><binary-for-input-value> StringString 指定字符串的二进制版本The binary version for the specified string

示例Example

此示例将“hello”字符串转换为二进制字符串:This example converts the "hello" string to a binary string:

binary('hello')

并返回以下结果:And returns this result:

"0110100001100101011011000110110001101111"

bodybody

返回操作在运行时的 body 输出。Return an action's body output at runtime. actions('<actionName>').outputs.body 的速记。Shorthand for actions('<actionName>').outputs.body. 请参阅 actionBody()actions()See actionBody() and actions().

body('<actionName>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 所需的操作 body 输出的名称The name for the action's body output that you want
返回值Return value 类型Type 说明Description
<action-body-output><action-body-output> StringString 指定操作的 body 输出The body output from the specified action

示例Example

此示例获取 Get user Twitter 操作的 body 输出:This example gets the body output from the Get user Twitter action:

body('Get_user')

并返回以下结果:And returns this result:

"body": {
    "FullName": "Contoso Corporation",
    "Location": "Generic Town, USA",
    "Id": 283541717,
    "UserName": "ContosoInc",
    "FollowersCount": 172,
    "Description": "Leading the way in transforming the digital workplace.",
    "StatusesCount": 93,
    "FriendsCount": 126,
    "FavouritesCount": 46,
    "ProfileImageUrl": "https://pbs.twimg.com/profile_images/908820389907722240/gG9zaHcd_400x400.jpg"
}

boolbool

返回值的布尔版本。Return the Boolean version for a value.

bool(<value>)
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 任意Any 要转换的值The value to convert
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 指定的值的布尔版本The Boolean version for the specified value

示例Example

这些示例将指定的值转换为布尔值:These examples convert the specified values to Boolean values:

bool(1)
bool(0)

并返回以下结果:And returns these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

coalescecoalesce

返回一个或多个参数中的第一个非 null 值。Return the first non-null value from one or more parameters. 空字符串、空数组和空对象不为 null。Empty strings, empty arrays, and empty objects are not null.

coalesce(<object_1>, <object_2>, ...)
参数Parameter 必须Required 类型Type 说明Description
<object_1>, <object_2>, ...<object_1>, <object_2>, ... Yes 任意,可以混用各种类型Any, can mix types 要检查是否为 null 的一个或多个项One or more items to check for null
返回值Return value 类型Type 说明Description
<first-non-null-item><first-non-null-item> 任意Any 第一个不为 null 的项或值。The first item or value that is not null. 如果所有参数均为 null,则此函数返回 null。If all parameters are null, this function returns null.

示例Example

这些示例返回指定值中的第一个非 null 值,当所有值均为 null 时返回 null:These examples return the first non-null value from the specified values, or null when all the values are null:

coalesce(null, true, false)
coalesce(null, 'hello', 'world')
coalesce(null, null, null)

并返回以下结果:And returns these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:"hello"Second example: "hello"
  • 第三个示例:nullThird example: null

concatconcat

组合两个或更多字符串,并返回组合后的字符串。Combine two or more strings, and return the combined string.

concat('<text1>', '<text2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<text1>, <text2>, ...<text1>, <text2>, ... Yes StringString 至少两个要组合的字符串At least two strings to combine
返回值Return value 类型Type 说明Description
<text1text2... ><text1text2...> StringString 基于组合后的输入字符串创建的字符串The string created from the combined input strings

示例Example

此示例将字符串“Hello”和“World”组合到一起:This example combines the strings "Hello" and "World":

concat('Hello', 'World')

并返回以下结果:"HelloWorld"And returns this result: "HelloWorld"

containscontains

检查集合是否包含某个特定项。Check whether a collection has a specific item. 当找到该项目时返回 true,找不到该项目时返回 false。Return true when the item is found, or return false when not found. 此函数区分大小写。This function is case-sensitive.

contains('<collection>', '<value>')
contains([<collection>], '<value>')

具体而言,此函数对以下集合类型起作用:Specifically, this function works on these collection types:

  • 字符串,在其中查找子字符串A string to find a substring
  • 数组,在其中查找值An array to find a value
  • 字典,在其中查找键A dictionary to find a key
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串、数组或字典String, Array, or Dictionary 要检查的集合The collection to check
<value><value> Yes 分别为字符串、数组或字典String, Array, or Dictionary, respectively 要查找的项The item to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到该项时返回 true。Return true when the item is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查字符串“hello world”中是否有子字符串“world”并返回 true:This example checks the string "hello world" for the substring "world" and returns true:

contains('hello world', 'world')

示例 2Example 2

此示例检查字符串“hello world”中是否有子字符串“universe”并返回 false:This example checks the string "hello world" for the substring "universe" and returns false:

contains('hello world', 'universe')

convertFromUtcconvertFromUtc

将时间戳从协调世界时 (UTC) 转换为目标时区。Convert a timestamp from Universal Time Coordinated (UTC) to the target time zone.

convertFromUtc('<timestamp>', '<destinationTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<destinationTimeZone><destinationTimeZone> Yes StringString 目标时区的名称。The name for the target time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为目标时区的时间戳The timestamp converted to the target time zone

示例 1Example 1

此示例将时间戳转换为指定的时区:This example converts a timestamp to the specified time zone:

convertFromUtc('2018-01-01T08:00:00.0000000Z', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T00:00:00.0000000"And returns this result: "2018-01-01T00:00:00.0000000"

示例 2Example 2

此示例将时间戳转换为指定的时区和格式:This example converts a timestamp to the specified time zone and format:

convertFromUtc('2018-01-01T08:00:00.0000000Z', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

convertTimeZoneconvertTimeZone

将时间戳从源时区转换为目标时区。Convert a timestamp from the source time zone to the target time zone.

convertTimeZone('<timestamp>', '<sourceTimeZone>', '<destinationTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<sourceTimeZone><sourceTimeZone> Yes StringString 源时区的名称。The name for the source time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<destinationTimeZone><destinationTimeZone> Yes StringString 目标时区的名称。The name for the target time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为目标时区的时间戳The timestamp converted to the target time zone

示例 1Example 1

此示例将源时区转换为目标时区:This example converts the source time zone to the target time zone:

convertTimeZone('2018-01-01T08:00:00.0000000Z', 'UTC', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T00:00:00.0000000"And returns this result: "2018-01-01T00:00:00.0000000"

示例 2Example 2

此示例将时区转换为指定的时区和格式:This example converts a time zone to the specified time zone and format:

convertTimeZone('2018-01-01T80:00:00.0000000Z', 'UTC', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

convertToUtcconvertToUtc

将时间戳从源时区转换为协调世界时 (UTC)。Convert a timestamp from the source time zone to Universal Time Coordinated (UTC).

convertToUtc('<timestamp>', '<sourceTimeZone>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<sourceTimeZone><sourceTimeZone> Yes StringString 源时区的名称。The name for the source time zone. 有关时区名称,请参阅 Microsoft 时区索引值,但你可能需要删除时区名称中的任何标点。For time zone names, see Microsoft Time Zone Index Values, but you might have to remove any punctuation from the time zone name.
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<converted-timestamp><converted-timestamp> StringString 已转换为 UTC 的时间戳The timestamp converted to UTC

示例 1Example 1

此示例将时间戳转换为 UTC:This example converts a timestamp to UTC:

convertToUtc('01/01/2018 00:00:00', 'Pacific Standard Time')

并返回以下结果:"2018-01-01T08:00:00.0000000Z"And returns this result: "2018-01-01T08:00:00.0000000Z"

示例 2Example 2

此示例将时间戳转换为 UTC:This example converts a timestamp to UTC:

convertToUtc('01/01/2018 00:00:00', 'Pacific Standard Time', 'D')

并返回以下结果:"Monday, January 1, 2018"And returns this result: "Monday, January 1, 2018"

createArraycreateArray

从多个输入返回数组。Return an array from multiple inputs. 对于单输入数组,请参阅 array()For single input arrays, see array().

createArray('<object1>', '<object2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<object1>, <object2>, ...<object1>, <object2>, ... Yes 任意,但不能混用Any, but not mixed 至少两个用于创建数组的项At least two items to create the array
返回值Return value 类型Type 说明Description
[<object1>, <object2>, ...][<object1>, <object2>, ...] ArrayArray 基于所有输入项创建的数组The array created from all the input items

示例Example

此示例基于以下输入创建数组:This example creates an array from these inputs:

createArray('h', 'e', 'l', 'l', 'o')

并返回以下结果:["h", "e", "l", "l", "o"]And returns this result: ["h", "e", "l", "l", "o"]

dataUridataUri

返回字符串的数据统一资源标识符 (URI)。Return a data uniform resource identifier (URI) for a string.

dataUri('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<data-uri><data-uri> StringString 输入字符串的数据 URIThe data URI for the input string

示例Example

此示例创建“hello”字符串的数据 URI:This example creates a data URI for the "hello" string:

dataUri('hello')

并返回以下结果:"data:text/plain;charset=utf-8;base64,aGVsbG8="And returns this result: "data:text/plain;charset=utf-8;base64,aGVsbG8="

dataUriToBinarydataUriToBinary

返回数据统一资源标识符 (URI) 的二进制版本。Return the binary version for a data uniform resource identifier (URI). 请使用此函数而非 decodeDataUri()Use this function rather than decodeDataUri(). 虽然这两个函数的工作方式相同,但首选 dataUriBinary()Although both functions work the same way, dataUriBinary() is preferred.

dataUriToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的数据 URIThe data URI to convert
返回值Return value 类型Type 说明Description
<binary-for-data-uri><binary-for-data-uri> StringString 数据 URI 的二进制版本The binary version for the data URI

示例Example

此示例创建以下数据 URI 的二进制版本:This example creates a binary version for this data URI:

dataUriToBinary('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:And returns this result:

"01100100011000010111010001100001001110100111010001100101011110000111010000101111011100000 1101100011000010110100101101110001110110110001101101000011000010111001001110011011001010111 0100001111010111010101110100011001100010110100111000001110110110001001100001011100110110010 10011011000110100001011000110000101000111010101100111001101100010010001110011100000111101"

dataUriToStringdataUriToString

返回数据统一资源标识符 (URI) 的字符串版本。Return the string version for a data uniform resource identifier (URI).

dataUriToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的数据 URIThe data URI to convert
返回值Return value 类型Type 说明Description
<string-for-data-uri><string-for-data-uri> StringString 数据 URI 的字符串版本The string version for the data URI

示例Example

此示例创建以下数据 URI 的字符串:This example creates a string for this data URI:

dataUriToString('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:"hello"And returns this result: "hello"

dayOfMonthdayOfMonth

基于时间戳返回月中的某天。Return the day of the month from a timestamp.

dayOfMonth('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-month><day-of-month> IntegerInteger 基于指定的时间戳返回月中的某天The day of the month from the specified timestamp

示例Example

此示例基于以下时间戳返回月中的某天:This example returns the number for the day of the month from this timestamp:

dayOfMonth('2018-03-15T13:27:36Z')

并返回以下结果:15And returns this result: 15

dayOfWeekdayOfWeek

基于时间戳返回周几。Return the day of the week from a timestamp.

dayOfWeek('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-week><day-of-week> IntegerInteger 指定的时间戳中的周几,其中周日为 0,周一为 1,依此类推The day of the week from the specified timestamp where Sunday is 0, Monday is 1, and so on

示例Example

此示例基于以下时间戳返回周几:This example returns the number for the day of the week from this timestamp:

dayOfWeek('2018-03-15T13:27:36Z')

并返回以下结果:4And returns this result: 4

dayOfYeardayOfYear

基于时间戳返回年中的某天。Return the day of the year from a timestamp.

dayOfYear('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
返回值Return value 类型Type 说明Description
<day-of-year><day-of-year> IntegerInteger 基于指定的时间戳返回年中的某天The day of the year from the specified timestamp

示例Example

此示例基于以下时间戳返回年中的某天:This example returns the number of the day of the year from this timestamp:

dayOfYear('2018-03-15T13:27:36Z')

并返回以下结果:74And returns this result: 74

decodeBase64(已弃用)decodeBase64 (deprecated)

此函数已弃用,因此请改用 base64ToString()This function is deprecated, so please use base64ToString() instead.

decodeDataUridecodeDataUri

返回数据统一资源标识符 (URI) 的二进制版本。Return the binary version for a data uniform resource identifier (URI). 请考虑使用 dataUriToBinary() 而非 decodeDataUri()Consider using dataUriToBinary(), rather than decodeDataUri(). 虽然这两个函数的工作方式相同,但首选 dataUriToBinary()Although both functions work the same way, dataUriToBinary() is preferred.

备注

Azure 逻辑应用会自动执行 base64 编码和解码,这意味着无需手动执行这些转换。Azure Logic Apps automatically performs base64 encoding and decoding, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

decodeDataUri('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的数据 URI 字符串The data URI string to decode
返回值Return value 类型Type 说明Description
<binary-for-data-uri><binary-for-data-uri> StringString 数据 URI 字符串的二进制版本The binary version for a data URI string

示例Example

此示例返回以下数据 URI 的二进制版本:This example returns the binary version for this data URI:

decodeDataUri('data:text/plain;charset=utf-8;base64,aGVsbG8=')

并返回以下结果:And returns this result:

"01100100011000010111010001100001001110100111010001100101011110000111010000101111011100000 1101100011000010110100101101110001110110110001101101000011000010111001001110011011001010111 0100001111010111010101110100011001100010110100111000001110110110001001100001011100110110010 10011011000110100001011000110000101000111010101100111001101100010010001110011100000111101"

decodeUriComponentdecodeUriComponent

返回一个字符串,并将其中的转义字符替换为解码后的版本。Return a string that replaces escape characters with decoded versions.

decodeUriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 包含要解码的转义字符的字符串The string with the escape characters to decode
返回值Return value 类型Type 说明Description
<decoded-uri><decoded-uri> StringString 包含解码后的转义字符的更新后字符串The updated string with the decoded escape characters

示例Example

此示例将以下字符串中的转义字符替换为解码后的版本:This example replaces the escape characters in this string with decoded versions:

decodeUriComponent('http%3A%2F%2Fcontoso.com')

并返回以下结果:"https://contoso.com"And returns this result: "https://contoso.com"

divdiv

返回将两个数字相除后的整数结果。Return the integer result from dividing two numbers. 若要获取余数结果,请参阅 mod()To get the remainder result, see mod().

div(<dividend>, <divisor>)
参数Parameter 必须Required 类型Type 说明Description
<dividend><dividend> Yes 整数或浮点数Integer or Float 要用作 divisor 的被除数的数字The number to divide by the divisor
<divisor><divisor> Yes 整数或浮点数Integer or Float 用作 dividend 的除数的数字,但不能为 0The number that divides the dividend, but cannot be 0
返回值Return value 类型Type 说明Description
<quotient-result><quotient-result> IntegerInteger 将第一个数字除以第二个数字后得到的整数结果The integer result from dividing the first number by the second number

示例Example

两个示例都将第一个数字除以第二个数字:Both examples divide the first number by the second number:

div(10, 5)
div(11, 5)

并返回以下结果:2And return this result: 2

encodeUriComponentencodeUriComponent

通过将 URL 不安全字符替换为转义字符来返回字符串的统一资源标识符 (URI) 编码版本。Return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters. 请考虑使用 uriComponent() 而非 encodeUriComponent()Consider using uriComponent(), rather than encodeUriComponent(). 虽然这两个函数的工作方式相同,但首选 uriComponent()Although both functions work the same way, uriComponent() is preferred.

备注

Azure 逻辑应用会自动执行 base64 编码和解码,这意味着无需手动执行这些转换。Azure Logic Apps automatically performs base64 encoding and decoding, which means that you don't have to manually perform these conversions. 但是,如果手动执行了这些转换,则可能会出现意外的显示行为,这不会影响实际的转换结果,只会影响它们的显示方式。However, if you do so, you might experience unexpected display behaviors, which don't affect the actual conversions, only how they are shown. 有关详细信息,请参阅隐式数据类型转换For more information, see Implicit data type conversions.

encodeUriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换为 URI 编码格式的字符串The string to convert to URI-encoded format
返回值Return value 类型Type 说明Description
<encoded-uri><encoded-uri> StringString 带有转义字符的 URI 编码字符串The URI-encoded string with escape characters

示例Example

此示例创建以下字符串的 URI 编码版本:This example creates a URI-encoded version for this string:

encodeUriComponent('https://contoso.com')

并返回以下结果:"http%3A%2F%2Fcontoso.com"And returns this result: "http%3A%2F%2Fcontoso.com"

emptyempty

检查集合是否为空。Check whether a collection is empty. 当集合为空时返回 true,不为空时返回 false。Return true when the collection is empty, or return false when not empty.

empty('<collection>')
empty([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串、数组或对象String, Array, or Object 要检查的集合The collection to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当集合为空时返回 true。Return true when the collection is empty. 不为空时返回 false。Return false when not empty.

示例Example

这些示例检查指定的集合是否为空:These examples check whether the specified collections are empty:

empty('')
empty('abc')

并返回以下结果:And returns these results:

  • 第一个示例:传递一个空字符串,所以此函数返回 trueFirst example: Passes an empty string, so the function returns true.
  • 第二个示例:传递字符串“abc”,所以此函数返回 falseSecond example: Passes the string "abc", so the function returns false.

endsWithendsWith

检查字符串是否以特定的子字符串结尾。Check whether a string ends with a specific substring. 当找到该子字符串时返回 true,找不到时返回 false。Return true when the substring is found, or return false when not found. 此函数不区分大小写。This function is not case-sensitive.

endsWith('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要检查的字符串The string to check
<searchText><searchText> Yes StringString 要查找的结尾子字符串The ending substring to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到结尾子字符串时返回 true。Return true when the ending substring is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查“hello world”字符串是否以“world”字符串结尾:This example checks whether the "hello world" string ends with the "world" string:

endsWith('hello world', 'world')

并返回以下结果:trueAnd returns this result: true

示例 2Example 2

此示例检查“hello world”字符串是否以“universe”字符串结尾:This example checks whether the "hello world" string ends with the "universe" string:

endsWith('hello world', 'universe')

并返回以下结果:falseAnd returns this result: false

equalsequals

检查两个值、表达式或对象是否相等。Check whether both values, expressions, or objects are equivalent. 当两者相等时返回 true,两者不相等时返回 false。Return true when both are equivalent, or return false when they're not equivalent.

equals('<object1>', '<object2>')
参数Parameter 必须Required 类型Type 说明Description
<object1>, <object2><object1>, <object2> Yes 各种Various 要比较的值、表达式或对象The values, expressions, or objects to compare
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当两者相等时返回 true。Return true when both are equivalent. 不相等时返回 false。Return false when not equivalent.

示例Example

这些示例检查指定的输入是否相等。These examples check whether the specified inputs are equivalent.

equals(true, 1)
equals('abc', 'abcd')

并返回以下结果:And returns these results:

  • 第一个示例:两个值相等,所以此函数返回 trueFirst example: Both values are equivalent, so the function returns true.
  • 第二个示例:两个值不相等,所以此函数返回 falseSecond example: Both values aren't equivalent, so the function returns false.

firstfirst

返回字符串或数组中的第一项。Return the first item from a string or array.

first('<collection>')
first([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 要在其中查找第一项的集合The collection where to find the first item
返回值Return value 类型Type 说明Description
<first-collection-item><first-collection-item> 任意Any 集合中的第一项The first item in the collection

示例Example

这些示例查找以下集合中的第一项:These examples find the first item in these collections:

first('hello')
first(createArray(0, 1, 2))

并返回以下结果:And return these results:

  • 第一个示例:"h"First example: "h"
  • 第二个示例:0Second example: 0

floatfloat

将浮点数的字符串版本转换为实际的浮点数。Convert a string version for a floating-point number to an actual floating point number. 仅当将自定义参数传递给应用(例如,逻辑应用或流)时,才使用此函数。You can use this function only when passing custom parameters to an app, for example, a logic app or flow.

float('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 包含要转换的有效浮点数的字符串The string that has a valid floating-point number to convert
返回值Return value 类型Type 说明Description
<float-value><float-value> FloatFloat 指定的字符串的浮点数The floating-point number for the specified string

示例Example

此示例创建以下浮点数的字符串版本:This example creates a string version for this floating-point number:

float('10.333')

并返回以下结果:10.333And returns this result: 10.333

formatDateTimeformatDateTime

以指定的格式返回时间戳。Return a timestamp in the specified format.

formatDateTime('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<reformatted-timestamp><reformatted-timestamp> StringString 采用指定格式的更新后时间戳The updated timestamp in the specified format

示例Example

此示例将时间戳转换为指定的格式:This example converts a timestamp to the specified format:

formatDateTime('03/15/2018 12:00:00', 'yyyy-MM-ddTHH:mm:ss')

并返回以下结果:"2018-03-15T12:00:00"And returns this result: "2018-03-15T12:00:00"

formDataMultiValuesformDataMultiValues

返回与操作的“表单数据”或“表单编码”输出中的键名称匹配的值组成的数组。 Return an array with values that match a key name in an action's form-data or form-encoded output.

formDataMultiValues('<actionName>', '<key>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 其输出中具有所需键值的操作The action whose output has the key value you want
<key><key> Yes StringString 需要获取其值的键的名称The name for the key whose value you want
返回值Return value 类型Type 说明Description
[<array-with-key-values>][<array-with-key-values>] ArrayArray 包含与指定键匹配的所有值的数组An array with all the values that match the specified key

示例Example

此示例基于指定操作的表单数据或表单编码输出中的“Subject”键的值创建数组。This example creates an array from the "Subject" key's value in the specified action's form-data or form-encoded output:

formDataMultiValues('Send_an_email', 'Subject')

并在数组中返回主题文本,例如:["Hello world"]And returns the subject text in an array, for example: ["Hello world"]

formDataValueformDataValue

返回与操作的“表单数据”或“表单编码”输出中的键名称匹配的单个值。 Return a single value that matches a key name in an action's form-data or form-encoded output. 如果此函数找到多个匹配项,此函数将引发错误。If the function finds more than one match, the function throws an error.

formDataValue('<actionName>', '<key>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 其输出中具有所需键值的操作The action whose output has the key value you want
<key><key> Yes StringString 需要获取其值的键的名称The name for the key whose value you want
返回值Return value 类型Type 说明Description
<key-value><key-value> StringString 指定的键中的值The value in the specified key

示例Example

此示例基于指定操作的表单数据或表单编码输出中的“Subject”键的值创建字符串。This example creates a string from the "Subject" key's value in the specified action's form-data or form-encoded output:

formDataValue('Send_an_email', 'Subject')

并以字符串形式返回主题文本,例如:"Hello world"And returns the subject text as a string, for example: "Hello world"

formatNumberformatNumber

根据指定的格式以字符串形式返回一个数字。Return a number as a string that's based on the specified format.

formatNumber(<number>, <format>, <locale>?)
参数Parameter 必须Required 类型Type 说明Description
<number><number> Yes 整数或双精度Integer or Double 要设置格式的值。The value that you want to format.
<format><format> Yes StringString 一个复合格式字符串,指定要使用的格式。A composite format string that specifies the format that you want to use. 有关支持的数字格式字符串,请参阅 number.ToString(<format>, <locale>) 支持的标准数字格式字符串For the supported numeric format strings, see Standard numeric format strings, which are supported by number.ToString(<format>, <locale>).
<locale><locale> No StringString 要使用的受 number.ToString(<format>, <locale>) 支持的区域设置。The locale to use as supported by number.ToString(<format>, <locale>). 如果未指定,默认值为 en-usIf not specified, the default value is en-us.
返回值Return value 类型Type 说明Description
<formatted-number><formatted-number> StringString 以字符串形式指定的数字,采用指定的格式。The specified number as a string in the format that you specified. 可将此返回值强制转换为 intfloatYou can cast this return value to an int or float.

示例 1Example 1

假设你要设置数字 1234567890 的格式。Suppose that you want to format the number 1234567890. 此示例将该数字的格式设置为字符串“1,234,567,890.00”。This example formats that number as the string "1,234,567,890.00".

formatNumber(1234567890, '0,0.00', 'en-us')

示例 2*Example 2"

假设你要设置数字 1234567890 的格式。Suppose that you want to format the number 1234567890. 此示例将该数字的格式设置为字符串“1.234.567.890,00”。This example formats the number to the string "1.234.567.890,00".

formatNumber(1234567890, '0,0.00', 'is-is')

示例 3Example 3

假设你要设置数字 17.35 的格式。Suppose that you want to format the number 17.35. 此示例将该数字的格式设置为字符串“$17.35”。This example formats the number to the string "$17.35".

formatNumber(17.36, 'C2')

示例 4Example 4

假设你要设置数字 17.35 的格式。Suppose that you want to format the number 17.35. 此示例将该数字的格式设置为字符串“17,35 kr”。This example formats the number to the string "17,35 kr".

formatNumber(17.36, 'C2', 'is-is')

getFutureTimegetFutureTime

返回当前时间戳加上指定的时间单位。Return the current timestamp plus the specified time units.

getFutureTime(<interval>, <timeUnit>, <format>?)
参数Parameter 必须Required 类型Type 说明Description
<间隔><interval> Yes IntegerInteger 要添加的指定时间单位数The number of specified time units to add
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 当前时间戳加上指定的时间单位数The current timestamp plus the specified number of time units

示例 1Example 1

假设当前时间戳是“2018-03-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-03-01T00:00:00.0000000Z". 此示例将 5 天加到该时间戳:This example adds five days to that timestamp:

getFutureTime(5, 'Day')

并返回以下结果:"2018-03-06T00:00:00.0000000Z"And returns this result: "2018-03-06T00:00:00.0000000Z"

示例 2Example 2

假设当前时间戳是“2018-03-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-03-01T00:00:00.0000000Z". 此示例加上 5 天,并将结果转换为“D”格式:This example adds five days and converts the result to "D" format:

getFutureTime(5, 'Day', 'D')

并返回以下结果:"Tuesday, March 6, 2018"And returns this result: "Tuesday, March 6, 2018"

getPastTimegetPastTime

返回当前时间戳减去指定的时间单位。Return the current timestamp minus the specified time units.

getPastTime(<interval>, <timeUnit>, <format>?)
参数Parameter 必须Required 类型Type 说明Description
<间隔><interval> Yes IntegerInteger 要减去的指定时间单位数The number of specified time units to subtract
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 当前时间戳减去指定的时间单位数The current timestamp minus the specified number of time units

示例 1Example 1

假设当前时间戳是“2018-02-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-02-01T00:00:00.0000000Z". 此示例从该时间戳减去 5 天:This example subtracts five days from that timestamp:

getPastTime(5, 'Day')

并返回以下结果:"2018-01-27T00:00:00.0000000Z"And returns this result: "2018-01-27T00:00:00.0000000Z"

示例 2Example 2

假设当前时间戳是“2018-02-01T00:00:00.0000000Z”。Suppose the current timestamp is "2018-02-01T00:00:00.0000000Z". 此示例减去 5 天,并将结果转换为“D”格式:This example subtracts five days and converts the result to "D" format:

getPastTime(5, 'Day', 'D')

并返回以下结果:"Saturday, January 27, 2018"And returns this result: "Saturday, January 27, 2018"

greatergreater

检查第一个值是否大于第二个值。Check whether the first value is greater than the second value. 如果第一个值大,则返回 true;如果第一个值小,则返回 false。Return true when the first value is more, or return false when less.

greater(<value>, <compareTo>)
greater('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否大于第二个值的第一个值。The first value to check whether greater than the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较值The comparison value
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值大于第二个值时返回 true。Return true when the first value is greater than the second value. 当第一个值等于或小于第二个值时返回 false。Return false when the first value is equal to or less than the second value.

示例Example

这些示例检查第一个值是否大于第二个值:These examples check whether the first value is greater than the second value:

greater(10, 5)
greater('apple', 'banana')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

greaterOrEqualsgreaterOrEquals

检查第一个值是否大于或等于第二个值。Check whether the first value is greater than or equal to the second value. 当第一个值大于或等于第二个值时返回 true,当第一个值小于第二个值时返回 false。Return true when the first value is greater or equal, or return false when the first value is less.

greaterOrEquals(<value>, <compareTo>)
greaterOrEquals('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否大于或等于第二个值的第一个值The first value to check whether greater than or equal to the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较值The comparison value
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值大于或等于第二个值时返回 true。Return true when the first value is greater than or equal to the second value. 当第一个值小于第二个值时返回 false。Return false when the first value is less than the second value.

示例Example

这些示例检查第一个值是否大于或等于第二个值:These examples check whether the first value is greater or equal than the second value:

greaterOrEquals(5, 5)
greaterOrEquals('apple', 'banana')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

GUIDguid

生成一个字符串形式的全局唯一标识符 (GUID),例如“c2ecc88d-88c8-4096-912c-d6f2e2b138ce”:Generate a globally unique identifier (GUID) as a string, for example, "c2ecc88d-88c8-4096-912c-d6f2e2b138ce":

guid()

此外,还可以为 GUID 指定与默认格式“D”(由连字符分隔的 32 位数字)不同的格式。Also, you can specify a different format for the GUID other than the default format, "D", which is 32 digits separated by hyphens.

guid('<format>')
参数Parameter 必须Required 类型Type 说明Description
<format><format> No StringString 表示返回的 GUID 的单一格式说明符A single format specifier for the returned GUID. 默认情况下,格式为“D”,但可以使用“N”、“D”、“B”、“P”或“X”。By default, the format is "D", but you can use "N", "D", "B", "P", or "X".
返回值Return value 类型Type 说明Description
<GUID-value><GUID-value> StringString 随机生成的 GUIDA randomly generated GUID

示例Example

此示例生成相同的 GUID,但它是 32 位的,以连字符分隔并括在括号中:This example generates the same GUID, but as 32 digits, separated by hyphens, and enclosed in parentheses:

guid('P')

并返回以下结果:"(c2ecc88d-88c8-4096-912c-d6f2e2b138ce)"And returns this result: "(c2ecc88d-88c8-4096-912c-d6f2e2b138ce)"

ifif

检查表达式为 true 还是 false。Check whether an expression is true or false. 根据结果返回指定的值。Based on the result, return a specified value. 从左到右评估参数。Parameters are evaluated from left to right.

if(<expression>, <valueIfTrue>, <valueIfFalse>)
参数Parameter 必须Required 类型Type 说明Description
<expression><expression> Yes 布尔Boolean 要检查的表达式The expression to check
<valueIfTrue><valueIfTrue> Yes 任意Any 当表达式为 true 时要返回的值The value to return when the expression is true
<valueIfFalse><valueIfFalse> Yes 任意Any 当表达式为 false 时要返回的值The value to return when the expression is false
返回值Return value 类型Type 说明Description
<specified-return-value><specified-return-value> 任意Any 根据表达式为 true 或 false 返回的指定值The specified value that returns based on whether the expression is true or false

示例Example

此示例返回 "yes",因为指定的表达式返回 true。This example returns "yes" because the specified expression returns true. 否则,此示例返回 "no"Otherwise, the example returns "no":

if(equals(1, 1), 'yes', 'no')

indexOfindexOf

返回子字符串的起始位置或索引值。Return the starting position or index value for a substring. 此函数不区分大小写,并且索引从数字 0 开始。This function is not case-sensitive, and indexes start with the number 0.

indexOf('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要查找的子字符串的字符串The string that has the substring to find
<searchText><searchText> Yes StringString 要查找的子字符串The substring to find
返回值Return value 类型Type 说明Description
<index-value><index-value> IntegerInteger 指定的子字符串的起始位置或索引值。The starting position or index value for the specified substring.

如果未找到该字符串,则返回数字 -1。If the string is not found, return the number -1.

示例Example

此示例查找“hello world”字符串中的“world”子字符串的起始索引值:This example finds the starting index value for the "world" substring in the "hello world" string:

indexOf('hello world', 'world')

并返回以下结果:6And returns this result: 6

intint

返回字符串的整数版本。Return the integer version for a string.

int('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的字符串The string to convert
返回值Return value 类型Type 说明Description
<integer-result><integer-result> IntegerInteger 指定的字符串的整数版本The integer version for the specified string

示例Example

此示例创建字符串“10”的整数版本:This example creates an integer version for the string "10":

int('10')

并返回以下结果:10And returns this result: 10

itemitem

当在针对数组的重复操作中使用时,返回在操作的当前迭代过程中数组中的当前项。When used inside a repeating action over an array, return the current item in the array during the action's current iteration. 还可以获取该项的属性中的值。You can also get the values from that item's properties.

item()
返回值Return value 类型Type 说明Description
<current-array-item><current-array-item> 任意Any 返回在操作的当前迭代中数组中的当前项The current item in the array for the action's current iteration

示例Example

此示例在 for-each 循环的当前迭代中从“Send_an_email”操作的当前消息中获取 body 元素:This example gets the body element from the current message for the "Send_an_email" action inside a for-each loop's current iteration:

item().body

itemsitems

返回 for-each 循环中每个周期的当前项。Return the current item from each cycle in a for-each loop. 请在 for-each 循环中使用此函数。Use this function inside the for-each loop.

items('<loopName>')
参数Parameter 必须Required 类型Type 说明Description
<loopName><loopName> Yes StringString for-each 循环的名称The name for the for-each loop
返回值Return value 类型Type 说明Description
<item><item> 任意Any 指定的 for-each 循环中当前周期中的项The item from the current cycle in the specified for-each loop

示例Example

此示例获取指定 for-each 循环的当前项:This example gets the current item from the specified for-each loop:

items('myForEachLoopName')

iterationIndexesiterationIndexes

位于 Until 循环中时,返回当前迭代的索引值。Return the index value for the current iteration inside an Until loop. 可以在嵌套式的 Until 循环中使用该函数。You can use this function inside nested Until loops.

iterationIndexes('<loopName>')
参数Parameter 必须Required 类型Type 说明Description
<loopName><loopName> Yes StringString Until 循环的名称The name for the Until loop
返回值Return value 类型Type 说明Description
<index><index> IntegerInteger 指定的 Until 循环中当前迭代的索引值The index value for the current iteration inside the specified Until loop

示例Example

此示例创建一个计数器变量,在 Until 循环中每迭代一次该变量就会递增 1,直至计数器值达到 5。This example creates a counter variable and increments that variable by one during each iteration in an Until loop until the counter value reaches five. 此示例还创建一个变量,用于跟踪每次迭代的当前索引。The example also creates a variable that tracks the current index for each iteration. 在 Until 循环中,在每次迭代过程中,该示例将递增计数器的值,然后将计数器值分配给当前索引值,接着再递增计数器的值。In the Until loop, during each iteration, the example increments the counter and then assigns the counter value to the current index value and then increments the counter. 在此循环中,此示例使用 iterationIndexes 函数引用当前迭代索引:While in the loop, this example references the current iteration index by using the iterationIndexes function:

iterationIndexes('Until_Max_Increment')

{
   "actions": {
      "Create_counter_variable": {
         "type": "InitializeVariable",
         "inputs": {
            "variables": [ 
               {
                  "name": "myCounter",
                  "type": "Integer",
                  "value": 0
               }
            ]
         },
         "runAfter": {}
      },
      "Create_current_index_variable": {
         "type": "InitializeVariable",
         "inputs": {
            "variables": [
               {
                  "name": "myCurrentLoopIndex",
                  "type": "Integer",
                  "value": 0
               }
            ]
         },
         "runAfter": {
            "Create_counter_variable": [ "Succeeded" ]
         }
      },
      "Until_Max_Increment": {
         "type": "Until",
         "actions": {
            "Assign_current_index_to_counter": {
               "type": "SetVariable",
               "inputs": {
                  "name": "myCurrentLoopIndex",
                  "value": "@variables('myCounter')"
               },
               "runAfter": {
                  "Increment_variable": [ "Succeeded" ]
               }
            },
            "Compose": {
               "inputs": "'Current index: ' @{iterationIndexes('Until_Max_Increment')}",
               "runAfter": {
                  "Assign_current_index_to_counter": [
                     "Succeeded"
                    ]
                },
                "type": "Compose"
            },           
            "Increment_variable": {
               "type": "IncrementVariable",
               "inputs": {
                  "name": "myCounter",
                  "value": 1
               },
               "runAfter": {}
            }
         },
         "expression": "@equals(variables('myCounter'), 5)",
         "limit": {
            "count": 60,
            "timeout": "PT1H"
         },
         "runAfter": {
            "Create_current_index_variable": [ "Succeeded" ]
         }
      }
   }
}

jsonjson

返回字符串或 XML 的 JavaScript 对象表示法 (JSON) 类型的值或对象。Return the JavaScript Object Notation (JSON) type value or object for a string or XML.

json('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 字符串或 XMLString or XML 要转换的字符串或 XMLThe string or XML to convert
返回值Return value 类型Type 说明Description
<JSON-result><JSON-result> JSON 本机类型或对象JSON native type or object 指定的字符串或 XML 的 JSON 本机类型的值或对象。The JSON native type value or object for the specified string or XML. 如果字符串为 null,则此函数返回一个空对象。If the string is null, the function returns an empty object.

示例 1Example 1

此示例将以下字符串转换为 JSON 值:This example converts this string to the JSON value:

json('[1, 2, 3]')

并返回以下结果:[1, 2, 3]And returns this result: [1, 2, 3]

示例 2Example 2

此示例将以下字符串转换为 JSON:This example converts this string to JSON:

json('{"fullName": "Sophia Owen"}')

并返回以下结果:And returns this result:

{
  "fullName": "Sophia Owen"
}

示例 3Example 3

此示例将以下 XML 转换为 JSON:This example converts this XML to JSON:

json(xml('<?xml version="1.0"?> <root> <person id='1'> <name>Sophia Owen</name> <occupation>Engineer</occupation> </person> </root>'))

并返回以下结果:And returns this result:

{
   "?xml": { "@version": "1.0" },
   "root": {
      "person": [ {
         "@id": "1",
         "name": "Sophia Owen",
         "occupation": "Engineer"
      } ]
   }
}

intersectionintersection

返回其中仅包含指定集合的共有项的一个集合。Return a collection that has only the common items across the specified collections. 某个项必须出现在传递给此函数的所有集合中才会出现在结果中。To appear in the result, an item must appear in all the collections passed to this function. 如果一个或多个项具有相同的名称,则具有该名称的最后一项将出现在结果中。If one or more items have the same name, the last item with that name appears in the result.

intersection([<collection1>], [<collection2>], ...)
intersection('<collection1>', '<collection2>', ...)
参数Parameter 必须Required 类型Type 说明Description
<collection1>, <collection2>, ...<collection1>, <collection2>, ... Yes 数组或对象,但不能为两者Array or Object, but not both 仅需从中获取共有项的各个集合The collections from where you want only the common items
返回值Return value 类型Type 说明Description
<common-items><common-items> 分别为数组或对象Array or Object, respectively 其中仅包含指定集合的共有项的一个集合A collection that has only the common items across the specified collections

示例Example

此示例查找以下数组中的共有项:This example finds the common items across these arrays:

intersection(createArray(1, 2, 3), createArray(101, 2, 1, 10), createArray(6, 8, 1, 2))

并返回“仅”包含这些项的数组:[1, 2]And returns an array with only these items: [1, 2]

joinjoin

返回一个字符串,它包含某个数组中的所有项并且以分隔符分隔每个字符。Return a string that has all the items from an array and has each character separated by a delimiter.

join([<collection>], '<delimiter>')
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes ArrayArray 包含要联接的项的数组The array that has the items to join
<delimiter><delimiter> Yes StringString 出现在结果字符串中的每个字符之间的分隔符The separator that appears between each character in the resulting string
返回值Return value 类型Type 说明Description
<char1><delimiter><char2><delimiter>...<char1><delimiter><char2><delimiter>... StringString 基于指定数组中的所有项创建的结果字符串The resulting string created from all the items in the specified array

示例Example

此示例基于以下数组中的所有项创建字符串,并且以指定的字符作为分隔符:This example creates a string from all the items in this array with the specified character as the delimiter:

join(createArray('a', 'b', 'c'), '.')

并返回以下结果:"a.b.c"And returns this result: "a.b.c"

lastlast

返回集合中的最后一个项。Return the last item from a collection.

last('<collection>')
last([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 要在其中查找最后一项的集合The collection where to find the last item
返回值Return value 类型Type 说明Description
<last-collection-item><last-collection-item> 分别为字符串或数组String or Array, respectively 集合中的最后一项The last item in the collection

示例Example

这些示例查找以下集合中的最后一项:These examples find the last item in these collections:

last('abcd')
last(createArray(0, 1, 2, 3))

并返回以下结果:And returns these results:

  • 第一个示例:"d"First example: "d"
  • 第二个示例:3Second example: 3

lastIndexOflastIndexOf

返回最后一次出现的子字符串的起始位置或索引值。Return the starting position or index value for the last occurrence of a substring. 此函数不区分大小写,并且索引从数字 0 开始。This function is not case-sensitive, and indexes start with the number 0.

lastIndexOf('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要查找的子字符串的字符串The string that has the substring to find
<searchText><searchText> Yes StringString 要查找的子字符串The substring to find
返回值Return value 类型Type 说明Description
<ending-index-value><ending-index-value> IntegerInteger 最后一次出现的指定子字符串的起始位置或索引值。The starting position or index value for the last occurrence of the specified substring.

如果未找到该字符串,则返回数字 -1。If the string is not found, return the number -1.

示例Example

此示例查找“hello world”字符串中最后一次出现的“world”子字符串的起始索引值:This example finds the starting index value for the last occurrence of the "world" substring in the "hello world" string:

lastIndexOf('hello world', 'world')

并返回以下结果:6And returns this result: 6

lengthlength

返回集合中的项数。Return the number of items in a collection.

length('<collection>')
length([<collection>])
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 包含要计数的项的集合The collection with the items to count
返回值Return value 类型Type 说明Description
<length-or-count><length-or-count> IntegerInteger 集合中的项数The number of items in the collection

示例Example

这些示例对以下集合中的项数进行计数:These examples count the number of items in these collections:

length('abcd')
length(createArray(0, 1, 2, 3))

并返回以下结果:4And return this result: 4

lessless

检查第一个值是否小于第二个值。Check whether the first value is less than the second value. 如果第一个值小,则返回 true;如果第一个值大,则返回 false。Return true when the first value is less, or return false when the first value is more.

less(<value>, <compareTo>)
less('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否小于第二个值的第一个值The first value to check whether less than the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较项The comparison item
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值小于第二个值时返回 true。Return true when the first value is less than the second value. 当第一个值等于或大于第二个值时返回 false。Return false when the first value is equal to or greater than the second value.

示例Example

这些示例检查第一个值是否小于第二个值。These examples check whether the first value is less than the second value.

less(5, 10)
less('banana', 'apple')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

lessOrEqualslessOrEquals

检查第一个值是否小于或等于第二个值。Check whether the first value is less than or equal to the second value. 当第一个值小于或等于第二个值时返回 true,当第一个值大时返回 false。Return true when the first value is less than or equal, or return false when the first value is more.

lessOrEquals(<value>, <compareTo>)
lessOrEquals('<value>', '<compareTo>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 整数、浮点数或字符串Integer, Float, or String 要检查是否小于或等于第二个值的第一个值The first value to check whether less than or equal to the second value
<compareTo><compareTo> Yes 分别为整数、浮点数或字符串Integer, Float, or String, respectively 比较项The comparison item
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当第一个值小于或等于第二个值时返回 true。Return true when the first value is less than or equal to the second value. 当第一个值大于第二个值时返回 false。Return false when the first value is greater than the second value.

示例Example

这些示例检查第一个值是否小于或等于第二个值。These examples check whether the first value is less or equal than the second value.

lessOrEquals(10, 10)
lessOrEquals('apply', 'apple')

并返回以下结果:And return these results:

  • 第一个示例:trueFirst example: true
  • 第二个示例:falseSecond example: false

listCallbackUrllistCallbackUrl

返回调用某个触发器或操作的“回调 URL”。Return the "callback URL" that calls a trigger or action. 此函数仅对适用于 HttpWebhookApiConnectionWebhook 连接器类型的触发器和操作起作用,对 ManualRecurrenceHTTPAPIConnection 类型不起作用。This function works only with triggers and actions for the HttpWebhook and ApiConnectionWebhook connector types, but not the Manual, Recurrence, HTTP, and APIConnection types.

listCallbackUrl()
返回值Return value 类型Type 说明Description
<callback-URL><callback-URL> StringString 触发器或操作的回调 URLThe callback URL for a trigger or action

示例Example

此示例显示了此函数可能会返回的示例回调 URL:This example shows a sample callback URL that this function might return:

"https://prod-01.chinanorth.logic.azure.com:443/workflows/<*workflow-ID*>/triggers/manual/run?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=<*signature-ID*>"

maxmax

返回列表中或包括两端数字在内的数组中的最大值。Return the highest value from a list or array with numbers that is inclusive at both ends.

max(<number1>, <number2>, ...)
max([<number1>, <number2>, ...])
参数Parameter 必须Required 类型Type 说明Description
<number1>, <number2>, ...<number1>, <number2>, ... Yes 整数、浮点数或两者Integer, Float, or both 需要从中获取最大值的数字集The set of numbers from which you want the highest value
[<number1>, <number2>, ...][<number1>, <number2>, ...] Yes 数组 - 整数、浮点数或两者Array - Integer, Float, or both 需要从中获取最大值的数字数组The array of numbers from which you want the highest value
返回值Return value 类型Type 说明Description
<max-value><max-value> 整数或浮点数Integer or Float 指定的数组或数字集中的最大值The highest value in the specified array or set of numbers

示例Example

这些示例获取数字集和数组中的最大值:These examples get the highest value from the set of numbers and the array:

max(1, 2, 3)
max(createArray(1, 2, 3))

并返回以下结果:3And return this result: 3

minmin

返回一组数字或数组中的最小值。Return the lowest value from a set of numbers or an array.

min(<number1>, <number2>, ...)
min([<number1>, <number2>, ...])
参数Parameter 必须Required 类型Type 说明Description
<number1>, <number2>, ...<number1>, <number2>, ... Yes 整数、浮点数或两者Integer, Float, or both 需要从中获取最小值的数字集The set of numbers from which you want the lowest value
[<number1>, <number2>, ...][<number1>, <number2>, ...] Yes 数组 - 整数、浮点数或两者Array - Integer, Float, or both 需要从中获取最小值的数字数组The array of numbers from which you want the lowest value
返回值Return value 类型Type 说明Description
<min-value><min-value> 整数或浮点数Integer or Float 指定的数字集或指定的数组中的最小值The lowest value in the specified set of numbers or specified array

示例Example

这些示例获取数字集和数组中的最小值:These examples get the lowest value in the set of numbers and the array:

min(1, 2, 3)
min(createArray(1, 2, 3))

并返回以下结果:1And return this result: 1

modmod

返回将两个数字相除后的余数。Return the remainder from dividing two numbers. 若要获取整数结果,请参阅 div()To get the integer result, see div().

mod(<dividend>, <divisor>)
参数Parameter 必须Required 类型Type 说明Description
<dividend><dividend> Yes 整数或浮点数Integer or Float 要用作 divisor 的被除数的数字The number to divide by the divisor
<divisor><divisor> Yes 整数或浮点数Integer or Float 用作 dividend 的除数的数字,但不能为 0。The number that divides the dividend, but cannot be 0.
返回值Return value 类型Type 说明Description
<modulo-result><modulo-result> 整数或浮点数Integer or Float 将第一个数字除以第二个数字后得到的余数The remainder from dividing the first number by the second number

示例Example

此示例将第一个数字除以第二个数字:This example divides the first number by the second number:

mod(3, 2)

并返回以下结果:1And return this result: 1

mulmul

返回将两个数字相乘得到的乘积。Return the product from multiplying two numbers.

mul(<multiplicand1>, <multiplicand2>)
参数Parameter 必须Required 类型Type 说明Description
<multiplicand1><multiplicand1> Yes 整数或浮点数Integer or Float 要与 multiplicand2 相乘的数字The number to multiply by multiplicand2
<multiplicand2><multiplicand2> Yes 整数或浮点数Integer or Float 要与 multiplicand1 相乘的数字The number that multiples multiplicand1
返回值Return value 类型Type 说明Description
<product-result><product-result> 整数或浮点数Integer or Float 将第一个数字乘以第二个数字后得到的乘积The product from multiplying the first number by the second number

示例Example

这些示例将第一个数字乘以第二个数字:These examples multiple the first number by the second number:

mul(1, 2)
mul(1.5, 2)

并返回以下结果:And return these results:

  • 第一个示例:2First example: 2
  • 第二个示例:3Second example 3

multipartBodymultipartBody

返回具有多个部分的操作输出中某个特定部分的正文。Return the body for a specific part in an action's output that has multiple parts.

multipartBody('<actionName>', <index>)
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 具有多部分输出的操作的名称The name for the action that has output with multiple parts
<index><index> Yes IntegerInteger 所需部分的索引值The index value for the part that you want
返回值Return value 类型Type 说明Description
<body><body> StringString 指定部分的正文The body for the specified part

notnot

检查表达式是否为 false。Check whether an expression is false. 当表达式为 false 时返回 true,当表达式为 true 时返回 false。Return true when the expression is false, or return false when true.

not(<expression>)
参数Parameter 必须Required 类型Type 说明Description
<expression><expression> Yes 布尔Boolean 要检查的表达式The expression to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当表达式为 false 时返回 true。Return true when the expression is false. 当表达式为 true 时返回 false。Return false when the expression is true.

示例 1Example 1

这些示例检查指定的表达式是否为 false:These examples check whether the specified expressions are false:

not(false)
not(true)

并返回以下结果:And return these results:

  • 第一个示例:表达式为 false,所以此函数返回 trueFirst example: The expression is false, so the function returns true.
  • 第二个示例:表达式为 true,所以此函数返回 falseSecond example: The expression is true, so the function returns false.

示例 2Example 2

这些示例检查指定的表达式是否为 false:These examples check whether the specified expressions are false:

not(equals(1, 2))
not(equals(1, 1))

并返回以下结果:And return these results:

  • 第一个示例:表达式为 false,所以此函数返回 trueFirst example: The expression is false, so the function returns true.
  • 第二个示例:表达式为 true,所以此函数返回 falseSecond example: The expression is true, so the function returns false.

or

检查是否至少一个表达式为 true。Check whether at least one expression is true. 当至少一个表达式为 true 时返回 true,当所有表达式均为 false 时返回 false。Return true when at least one expression is true, or return false when all are false.

or(<expression1>, <expression2>, ...)
参数Parameter 必须Required 类型Type 说明Description
<expression1>, <expression2>, ...<expression1>, <expression2>, ... Yes 布尔Boolean 要检查的表达式The expressions to check
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当至少一个表达式为 true 时返回 true。Return true when at least one expression is true. 当所有表达式均为 false 时返回 false。Return false when all expressions are false.

示例 1Example 1

这些示例检查是否至少一个表达式为 true:These examples check whether at least one expression is true:

or(true, false)
or(false, false)

并返回以下结果:And return these results:

  • 第一个示例:至少一个表达式为 true,所以此函数返回 trueFirst example: At least one expression is true, so the function returns true.
  • 第二个示例:两个表达式均为 false,所以此函数返回 falseSecond example: Both expressions are false, so the function returns false.

示例 2Example 2

这些示例检查是否至少一个表达式为 true:These examples check whether at least one expression is true:

or(equals(1, 1), equals(1, 2))
or(equals(1, 2), equals(1, 3))

并返回以下结果:And return these results:

  • 第一个示例:至少一个表达式为 true,所以此函数返回 trueFirst example: At least one expression is true, so the function returns true.
  • 第二个示例:两个表达式均为 false,所以此函数返回 falseSecond example: Both expressions are false, so the function returns false.

outputsoutputs

返回操作在运行时的输出。Return an action's outputs at runtime. 使用此函数,而不是在逻辑应用设计器中解析为 outputs()actionOutputs()Use this function, rather than actionOutputs(), which resolves to outputs() in the Logic App Designer. 虽然这两个函数的工作方式相同,但首选 outputs()Although both functions work the same way, outputs() is preferred.

outputs('<actionName>')
参数Parameter 必须Required 类型Type 说明Description
<actionName><actionName> Yes StringString 所需的操作输出的名称The name for the action's output that you want
返回值Return value 类型Type 说明Description
<output><output> StringString 指定操作的输出The output from the specified action

示例Example

此示例获取 Twitter 操作 Get user 的输出:This example gets the output from the Twitter action Get user:

outputs('Get_user')

并返回以下结果:And returns this result:

{
  "statusCode": 200,
  "headers": {
    "Pragma": "no-cache",
    "Vary": "Accept-Encoding",
    "x-ms-request-id": "a916ec8f52211265d98159adde2efe0b",
    "X-Content-Type-Options": "nosniff",
    "Timing-Allow-Origin": "*",
    "Cache-Control": "no-cache",
    "Date": "Mon, 09 Apr 2018 18:47:12 GMT",
    "Set-Cookie": "ARRAffinity=b9400932367ab5e3b6802e3d6158afffb12fcde8666715f5a5fbd4142d0f0b7d;Path=/;HttpOnly;Domain=twitter-wus.azconn-wus.p.chinacloudsites.cn",
    "X-AspNet-Version": "4.0.30319",
    "X-Powered-By": "ASP.NET",
    "Content-Type": "application/json; charset=utf-8",
    "Expires": "-1",
    "Content-Length": "339"
  },
  "body": {
    "FullName": "Contoso Corporation",
    "Location": "Generic Town, USA",
    "Id": 283541717,
    "UserName": "ContosoInc",
    "FollowersCount": 172,
    "Description": "Leading the way in transforming the digital workplace.",
    "StatusesCount": 93,
    "FriendsCount": 126,
    "FavouritesCount": 46,
    "ProfileImageUrl": "https://pbs.twimg.com/profile_images/908820389907722240/gG9zaHcd_400x400.jpg"
  }
}

参数parameters

返回工作流定义中描述的参数的值。Return the value for a parameter that is described in your workflow definition.

parameters('<parameterName>')
参数Parameter 必须Required 类型Type 说明Description
<parameterName><parameterName> Yes StringString 需要获取其值的参数的名称。The name for the parameter whose value you want
返回值Return value 类型Type 说明Description
<parameter-value><parameter-value> 任意Any 指定的参数的值The value for the specified parameter

示例Example

假设具有以下 JSON 值:Suppose that you have this JSON value:

{
  "fullName": "Sophia Owen"
}

此示例获取指定参数的值:This example gets the value for the specified parameter:

parameters('fullName')

并返回以下结果:"Sophia Owen"And returns this result: "Sophia Owen"

randrand

返回指定范围(仅包括起端在内)中的一个随机整数。Return a random integer from a specified range, which is inclusive only at the starting end.

rand(<minValue>, <maxValue>)
参数Parameter 必须Required 类型Type 说明Description
<minValue><minValue> Yes IntegerInteger 范围中的最小整数The lowest integer in the range
<maxValue><maxValue> Yes IntegerInteger 此函数可以返回的范围中的最大整数之后的整数The integer that follows the highest integer in the range that the function can return
返回值Return value 类型Type 说明Description
<random-result><random-result> IntegerInteger 从指定范围中返回的随机整数The random integer returned from the specified range

示例Example

此示例从指定范围内获取一个随机整数,不包括最大值:This example gets a random integer from the specified range, excluding the maximum value:

rand(1, 5)

并返回下列数字之一作为结果:1234And returns one of these numbers as the result: 1, 2, 3, or 4

rangerange

返回以指定整数开头的一个整数数组。Return an integer array that starts from a specified integer.

range(<startIndex>, <count>)
参数Parameter 必须Required 类型Type 说明Description
<startIndex><startIndex> Yes IntegerInteger 作为数组开头的第一项的整数值An integer value that starts the array as the first item
<count><count> Yes IntegerInteger 数组中的整数个数The number of integers in the array
返回值Return value 类型Type 说明Description
[<range-result>][<range-result>] ArrayArray 从指定索引开始的整数组成的数组The array with integers starting from the specified index

示例Example

此示例创建一个整数数组,从指定索引开始,并包含指定数目的整数:This example creates an integer array that starts from the specified index and has the specified number of integers:

range(1, 4)

并返回以下结果:[1, 2, 3, 4]And returns this result: [1, 2, 3, 4]

replacereplace

将子字符串替换为指定字符串,并返回结果字符串。Replace a substring with the specified string, and return the result string. 此函数区分大小写。This function is case-sensitive.

replace('<text>', '<oldText>', '<newText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要替换的子字符串的字符串The string that has the substring to replace
<oldText><oldText> Yes StringString 要替换的子字符串The substring to replace
<newText><newText> Yes StringString 替换字符串The replacement string
返回值Return value 类型Type 说明Description
<updated-text><updated-text> StringString 替换子字符串后得到的更新后字符串The updated string after replacing the substring

如果未找到子字符串,则返回原始字符串。If the substring is not found, return the original string.

示例Example

此示例查找“the old string”中的“old”子字符串并将“old”替换为“new”:This example finds the "old" substring in "the old string" and replaces "old" with "new":

replace('the old string', 'old', 'new')

并返回以下结果:"the new string"And returns this result: "the new string"

removePropertyremoveProperty

从对象中删除属性,并返回更新后的对象。Remove a property from an object and return the updated object. 如果尝试删除的属性不存在,此函数会返回原始对象。If the property that you try to remove doesn't exist, the function returns the original object.

removeProperty(<object>, '<property>')
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要从中删除属性的 JSON 对象The JSON object from where you want to remove a property
<property><property> Yes StringString 要删除的属性的名称The name for the property to remove
返回值Return value 类型Type 说明Description
<updated-object><updated-object> ObjectObject 不具有指定属性的更新后 JSON 对象The updated JSON object without the specified property

若要从现有属性中删除子属性,请使用以下语法:To remove a child property from an existing property, use this syntax:

removeProperty(<object>['<parent-property>'], '<child-property>')
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要删除其属性的 JSON 对象The JSON object whose property you want to remove
<parent-property><parent-property> Yes StringString 要删除其子属性的父属性的名称The name for parent property with the child property that you want to remove
<child-property><child-property> Yes StringString 要删除的子属性的名称The name for the child property to remove
返回值Return value 类型Type 说明Description
<updated-object><updated-object> ObjectObject 删除了其子属性的已更新 JSON 对象The updated JSON object whose child property that you removed

示例 1Example 1

此示例从 JSON 对象(此对象通过 JSON() 函数从字符串转换为 JSON)中删除 middleName 属性,并返回更新后的对象:This example removes the middleName property from a JSON object, which is converted from a string to JSON by using the JSON() function, and returns the updated object:

removeProperty(json('{ "firstName": "Sophia", "middleName": "Anne", "surName": "Owen" }'), 'middleName')

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "firstName": "Sophia",
   "middleName": "Anne",
   "surName": "Owen"
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "firstName": "Sophia",
   "surName": "Owen"
}

示例 2Example 2

此示例从 JSON 对象(此对象通过 JSON() 函数从字符串转换为 JSON)中的 customerName 父属性中删除 middleName 子属性,并返回更新后的对象:This example removes the middleName child property from a customerName parent property in a JSON object, which is converted from a string to JSON by using the JSON() function, and returns the updated object:

removeProperty(json('{ "customerName": { "firstName": "Sophia", "middleName": "Anne", "surName": "Owen" } }')['customerName'], 'middleName')

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "customerName": {
      "firstName": "Sophia",
      "middleName": "Anne",
      "surName": "Owen"
   }
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "customerName": {
      "firstName": "Sophia",
      "surName": "Owen"
   }
}

resultresult

返回指定的范围受限操作(例如 For_eachUntilScope 操作)中所有操作的输入和输出。Return the inputs and outputs from all the actions that are inside the specified scoped action, such as a For_each, Until, or Scope action. 此函数用于从失败的操作中返回结果,方便你诊断和处理异常。This function is useful returning the results from a failed action so that you can diagnose and handle exceptions. 有关详细信息,请参阅获取失败的上下文和结果For more information, see Get context and results for failures.

result('<scopedActionName>')
参数Parameter 必须Required 类型Type 说明Description
<scopedActionName><scopedActionName> Yes StringString 将会从其返回所有内部操作的输入和输出的范围受限操作的名称。The name of the scoped action from which to return the inputs and outputs from all the inner actions
返回值Return value 类型Type 说明Description
<array-object><array-object> 数组对象Array object 一个数组,其中包含显示在指定的范围受限操作中的每个操作的输入和输出数组An array that contains arrays of inputs and outputs from each action that appears inside the specified scoped action

示例Example

此示例返回 HTTP 操作的每个迭代的输入和输出,该操作位于 For_each 循环中,在 Compose 操作中使用 result() 函数:This example returns the inputs and outputs from each iteration of an HTTP action inside that's inside a For_each loop by using the result() function in the Compose action:

{
   "actions": {
      "Compose": {
         "inputs": "@result('For_each')",
         "runAfter": {
            "For_each": [
               "Succeeded"
            ]
         },
         "type": "compose"
      },
      "For_each": {
         "actions": {
            "HTTP": {
               "inputs": {
                  "method": "GET",
                  "uri": "https://httpstat.us/200"
               },
               "runAfter": {},
               "type": "Http"
            }
         },
         "foreach": "@triggerBody()",
         "runAfter": {},
         "type": "Foreach"
      }
   }
}

下面是示例返回的数组可能的外观,其中的外部 outputs 对象包含 For_each 操作中每个操作迭代的输入和输出。Here's how the example returned array might look where the outer outputs object contains the inputs and outputs from each iteration of the actions inside the For_each action.

[
   {
      "name": "HTTP",
      "outputs": [
         {
            "name": "HTTP",
            "inputs": {
               "uri": "https://httpstat.us/200",
               "method": "GET"
            },
            "outputs": {
               "statusCode": 200,
               "headers": {
                   "X-AspNetMvc-Version": "5.1",
                   "Access-Control-Allow-Origin": "*",
                   "Cache-Control": "private",
                   "Date": "Tue, 20 Aug 2019 22:15:37 GMT",
                   "Set-Cookie": "ARRAffinity=0285cfbea9f2ee7",
                   "Server": "Microsoft-IIS/10.0",
                   "X-AspNet-Version": "4.0.30319",
                   "X-Powered-By": "ASP.NET",
                   "Content-Length": "0"
               },
               "startTime": "2019-08-20T22:15:37.6919631Z",
               "endTime": "2019-08-20T22:15:37.95762Z",
               "trackingId": "6bad3015-0444-4ccd-a971-cbb0c99a7.....",
               "clientTrackingId": "085863526764.....",
               "code": "OK",
               "status": "Succeeded"
            }
         },
         {
            "name": "HTTP",
            "inputs": {
               "uri": "https://httpstat.us/200",
               "method": "GET"
            },
            "outputs": {
            "statusCode": 200,
               "headers": {
                   "X-AspNetMvc-Version": "5.1",
                   "Access-Control-Allow-Origin": "*",
                   "Cache-Control": "private",
                   "Date": "Tue, 20 Aug 2019 22:15:37 GMT",
                   "Set-Cookie": "ARRAffinity=0285cfbea9f2ee7",
                   "Server": "Microsoft-IIS/10.0",
                   "X-AspNet-Version": "4.0.30319",
                   "X-Powered-By": "ASP.NET",
                   "Content-Length": "0"
               },
               "startTime": "2019-08-20T22:15:37.6919631Z",
               "endTime": "2019-08-20T22:15:37.95762Z",
               "trackingId": "9987e889-981b-41c5-aa27-f3e0e59bf69.....",
               "clientTrackingId": "085863526764.....",
               "code": "OK",
               "status": "Succeeded"
            }
         }
      ]
   }
]

setPropertysetProperty

设置 JSON 对象的属性值并返回更新的对象。Set the value for JSON object's property and return the updated object. 如果尝试设置的属性不存在,则会为对象添加该属性。If the property that you try to set doesn't exist, the property gets added to the object. 若要添加新属性,请使用 addProperty() 函数。To add a new property, use the addProperty() function.

setProperty(<object>, '<property>', <value>)
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要设置其属性的 JSON 对象The JSON object whose property you want to set
<property><property> Yes StringString 要设置的现有属性或新属性的名称The name for the existing or new property to set
<value><value> Yes 任意Any 要为指定属性设置的值The value to set for the specified property

若要在子对象中设置子属性,请改用嵌套式 setProperty() 调用。To set the child property in a child object, use a nested setProperty() call instead. 否则,函数仅返回子对象作为输出。Otherwise, the function returns only the child object as output.

setProperty(<object>['<parent-property>'], '<parent-property>', setProperty(<object>['parentProperty'], '<child-property>', <value>))
参数Parameter 必须Required 类型Type 说明Description
<object><object> Yes ObjectObject 要设置其属性的 JSON 对象The JSON object whose property you want to set
<parent-property><parent-property> Yes StringString 要设置其子属性的父属性的名称The name for parent property with the child property that you want to set
<child-property><child-property> Yes StringString 要设置的子属性的名称The name for the child property to set
<value><value> Yes 任意Any 要为指定属性设置的值The value to set for the specified property
返回值Return value 类型Type 说明Description
<updated-object><updated-object> ObjectObject 设置了其属性的更新后 JSON 对象The updated JSON object whose property you set

示例 1Example 1

此示例在 JSON 对象中设置 surName 属性,可通过 JSON() 函数将其从字符串转换为 JSON。This example sets the surName property in a JSON object, which is converted from a string to JSON by using the JSON() function. 该函数将指定的值分配给属性,并返回更新后的对象:The function assigns the specified value to the property and returns the updated object:

setProperty(json('{ "firstName": "Sophia", "surName": "Owen" }'), 'surName', 'Hartnett')

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "firstName": "Sophia",
   "surName": "Owen"
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "firstName": "Sophia",
   "surName": "Hartnett"
}

示例 2Example 2

此示例为 JSON 对象中的 customerName 父属性设置 surName 子属性,可通过 JSON() 函数将其从字符串转换为 JSON。This example sets the surName child property for the customerName parent property in a JSON object, which is converted from a string to JSON by using the JSON() function. 该函数将指定的值分配给属性,并返回更新后的对象:The function assigns the specified value to the property and returns the updated object:

setProperty(json('{ "customerName": { "firstName": "Sophia", "surName": "Owen" } }'), 'customerName', setProperty(json('{ "customerName": { "firstName": "Sophia", "surName": "Owen" } }')['customerName'], 'surName', 'Hartnett'))

下面是当前的 JSON 对象:Here's the current JSON object:

{
   "customerName": {
      "firstName": "Sophie",
      "surName": "Owen"
   }
}

下面是已更新的 JSON 对象:Here's the updated JSON object:

{
   "customerName": {
      "firstName": "Sophie",
      "surName": "Hartnett"
   }
}

skipskip

删除集合开头的项,并返回所有其他项。Remove items from the front of a collection, and return all the other items.

skip([<collection>], <count>)
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes ArrayArray 要删除其项的集合The collection whose items you want to remove
<count><count> Yes IntegerInteger 要从开头删除的项数(一个正整数)A positive integer for the number of items to remove at the front
返回值Return value 类型Type 说明Description
[<updated-collection>][<updated-collection>] ArrayArray 删除指定项后得到的更新后的集合The updated collection after removing the specified items

示例Example

此示例从指定数组的开头删除一个项(数字 0):This example removes one item, the number 0, from the front of the specified array:

skip(createArray(0, 1, 2, 3), 1)

并返回包含剩余项的以下数组:[1,2,3]And returns this array with the remaining items: [1,2,3]

splitsplit

根据原始字符串中指定的分隔符字符,返回一个包含子字符串(以逗号分隔)的数组。Return an array that contains substrings, separated by commas, based on the specified delimiter character in the original string.

split('<text>', '<delimiter>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 根据原始字符串中指定的分隔符将分隔成子字符串的字符串The string to separate into substrings based on the specified delimiter in the original string
<delimiter><delimiter> Yes StringString 原始字符串中用作分隔符的字符The character in the original string to use as the delimiter
返回值Return value 类型Type 说明Description
[<substring1>,<substring2>,...][<substring1>,<substring2>,...] ArrayArray 一个数组,其中包含从原始字符串返回以逗号分隔的子字符串An array that contains substrings from the original string, separated by commas

示例Example

此示例根据作为分隔符的指定字符,从指定字符串创建具有子字符串的数组:This example creates an array with substrings from the specified string based on the specified character as the delimiter:

split('a_b_c', '_')

并将此数组作为以下结果返回:["a","b","c"]And returns this array as the result: ["a","b","c"]

startOfDaystartOfDay

返回时间戳中的天的开始时间。Return the start of the day for a timestamp.

startOfDay('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该天的零小时标记开始The specified timestamp but starting at the zero-hour mark for the day

示例Example

此示例查找以下时间戳中的天的开始时间:This example finds the start of the day for this timestamp:

startOfDay('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-15T00:00:00.0000000Z"And returns this result: "2018-03-15T00:00:00.0000000Z"

startOfHourstartOfHour

返回时间戳中的小时的开始时间。Return the start of the hour for a timestamp.

startOfHour('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该小时的零分钟标记开始The specified timestamp but starting at the zero-minute mark for the hour

示例Example

此示例查找以下时间戳中的小时的开始时间:This example finds the start of the hour for this timestamp:

startOfHour('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-15T13:00:00.0000000Z"And returns this result: "2018-03-15T13:00:00.0000000Z"

startOfMonthstartOfMonth

返回时间戳中的月份的开始时间。Return the start of the month for a timestamp.

startOfMonth('<timestamp>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 指定的时间戳,但从该月第一天的零小时标记开始The specified timestamp but starting on the first day of the month at the zero-hour mark

示例 1Example 1

此示例查找以下时间戳中月份的开始时间:This example returns the start of the month for this timestamp:

startOfMonth('2018-03-15T13:30:30Z')

并返回以下结果:"2018-03-01T00:00:00.0000000Z"And returns this result: "2018-03-01T00:00:00.0000000Z"

示例 2Example 2

此示例返回此时间戳的月份的开始时间(采用指定格式):This example returns the start of the month in the specified format for this timestamp:

startOfMonth('2018-03-15T13:30:30Z', 'yyyy-MM-dd')

并返回以下结果:"2018-03-01"And returns this result: "2018-03-01"

startsWithstartsWith

检查字符串是否以特定的子字符串开头。Check whether a string starts with a specific substring. 当找到该子字符串时返回 true,找不到时返回 false。Return true when the substring is found, or return false when not found. 此函数不区分大小写。This function is not case-sensitive.

startsWith('<text>', '<searchText>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要检查的字符串The string to check
<searchText><searchText> Yes StringString 要查找的起始字符串The starting string to find
返回值Return value 类型Type 说明Description
true 或 falsetrue or false 布尔Boolean 当找到起始子字符串时返回 true。Return true when the starting substring is found. 找不到时返回 false。Return false when not found.

示例 1Example 1

此示例检查“hello world”字符串是否以“hello”子字符串开头:This example checks whether the "hello world" string starts with the "hello" substring:

startsWith('hello world', 'hello')

并返回以下结果:trueAnd returns this result: true

示例 2Example 2

此示例检查“hello world”字符串是否以“greetings”子字符串开头:This example checks whether the "hello world" string starts with the "greetings" substring:

startsWith('hello world', 'greetings')

并返回以下结果:falseAnd returns this result: false

stringstring

返回值的字符串版本。Return the string version for a value.

string(<value>)
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes 任意Any 要转换的值。The value to convert. 如果此值为 NULL 或者计算结果为 NULL,则此值将转换为空字符串 ("") 值。If this value is null or evaluates to null, the value is converted to an empty string ("") value.

例如,如果将字符串变量分配给不存在的属性(可以使用 ? 运算符对其进行访问),则 NULL 值将转换为空字符串。For example, if you assign a string variable to a non-existent property, which you can access with the ? operator, the null value is converted to an empty string. 但是,比较 NULL 值与比较空字符串有所不同。However, comparing a null value isn't the same as comparing an empty string.

返回值Return value 类型Type 说明Description
<string-value><string-value> StringString 指定的值的字符串版本。The string version for the specified value. 如果 value 参数为 NULL 或计算结果为 NULL,则此值将作为空字符串 ("") 值返回。If the value parameter is null or evaluates to null, this value is returned as an empty string ("") value.

示例 1Example 1

此示例创建以下数字的字符串版本:This example creates the string version for this number:

string(10)

并返回以下结果:"10"And returns this result: "10"

示例 2Example 2

此示例为指定的 JSON 对象创建字符串并使用反斜杠字符 (\) 作为双引号 (") 的转义字符。This example creates a string for the specified JSON object and uses the backslash character (\) as an escape character for the double-quotation mark (").

string( { "name": "Sophie Owen" } )

并返回以下结果:"{ \\"name\\": \\"Sophie Owen\\" }"And returns this result: "{ \\"name\\": \\"Sophie Owen\\" }"

subsub

返回第一个数字减去第二个数字得到的结果。Return the result from subtracting the second number from the first number.

sub(<minuend>, <subtrahend>)
参数Parameter 必须Required 类型Type 说明Description
<minuend><minuend> Yes 整数或浮点数Integer or Float 要从中减去 subtrahend 的数字The number from which to subtract the subtrahend
<subtrahend><subtrahend> Yes 整数或浮点数Integer or Float 要从 minuend 中减去的数字The number to subtract from the minuend
返回值Return value 类型Type 说明Description
<result><result> 整数或浮点数Integer or Float 第一个数字减去第二个数字得到的结果The result from subtracting the second number from the first number

示例Example

此示例从第一个数字中减去第二个数字:This example subtracts the second number from the first number:

sub(10.3, .3)

并返回以下结果:10And returns this result: 10

substringsubstring

返回字符串中的字符,从指定的位置或索引开始。Return characters from a string, starting from the specified position, or index. 索引值从数字 0 开始。Index values start with the number 0.

substring('<text>', <startIndex>, <length>)
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 所需字符所在的字符串The string whose characters you want
<startIndex><startIndex> Yes IntegerInteger 一个等于或大于 0 的正数,需将其用作起始位置或索引值A positive number equal to or greater than 0 that you want to use as the starting position or index value
<length><length> Yes IntegerInteger 希望子字符串中具有的字符数(正数)A positive number of characters that you want in the substring
返回值Return value 类型Type 说明Description
<substring-result><substring-result> StringString 包含指定字符数的子字符串,从源字符串中的指定索引位置开始A substring with the specified number of characters, starting at the specified index position in the source string

示例Example

此示例基于指定的字符串从索引值 6 开始创建一个五字符的子字符串:This example creates a five-character substring from the specified string, starting from the index value 6:

substring('hello world', 6, 5)

并返回以下结果:"world"And returns this result: "world"

subtractFromTimesubtractFromTime

从时间戳中减去一定数目的时间单位。Subtract a number of time units from a timestamp. 另请参阅 getPastTimeSee also getPastTime.

subtractFromTime('<timestamp>', <interval>, '<timeUnit>', '<format>'?)
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 包含时间戳的字符串The string that contains the timestamp
<间隔><interval> Yes IntegerInteger 要减去的指定时间单位数The number of specified time units to subtract
<timeUnit><timeUnit> Yes StringString 间隔使用的时间单位:“秒”、“分钟”、“小时”、“日”、“周”、“月”、“年”The unit of time to use with interval: "Second", "Minute", "Hour", "Day", "Week", "Month", "Year"
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<updated-timestamp><updated-timestamp> StringString 时间戳减去指定的时间单位数The timestamp minus the specified number of time units

示例 1Example 1

此示例从以下时间戳中减去 1 天:This example subtracts one day from this timestamp:

subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day')

并返回以下结果:"2018-01-01T00:00:00:0000000Z"And returns this result: "2018-01-01T00:00:00:0000000Z"

示例 2Example 2

此示例从以下时间戳中减去 1 天:This example subtracts one day from this timestamp:

subtractFromTime('2018-01-02T00:00:00Z', 1, 'Day', 'D')

并使用可选的“D”格式返回以下结果:"Monday, January, 1, 2018"And returns this result using the optional "D" format: "Monday, January, 1, 2018"

taketake

返回集合开头的项。Return items from the front of a collection.

take('<collection>', <count>)
take([<collection>], <count>)
参数Parameter 必须Required 类型Type 说明Description
<collection><collection> Yes 字符串或数组String or Array 所需项所在的集合The collection whose items you want
<count><count> Yes IntegerInteger 从开头算起所需的项数(一个正整数)A positive integer for the number of items that you want from the front
返回值Return value 类型Type 说明Description
<subset> or [<subset>]<subset> or [<subset>] 分别为字符串或数组String or Array, respectively 一个字符串或数组,其中包含来自原始集合开头的指定数目的项A string or array that has the specified number of items taken from the front of the original collection

示例Example

这些示例从以下集合的开头获取指定的项数:These examples get the specified number of items from the front of these collections:

take('abcde', 3)
take(createArray(0, 1, 2, 3, 4), 3)

并返回以下结果:And return these results:

  • 第一个示例:"abc"First example: "abc"
  • 第二个示例:[0, 1, 2]Second example: [0, 1, 2]

ticksticks

返回自 0001 年 1 月 1 日午夜 12:00:00(或 C# 中的 DateTime.Ticks)到指定时间戳的间隔为 100 毫微秒的时钟周期数。Returns the number of ticks, which are 100-nanosecond intervals, since January 1, 0001 12:00:00 midnight (or DateTime.Ticks in C#) up to the specified timestamp. 有关详细信息,请参阅此主题:DateTime.Ticks 属性(系统)For more information, see this topic: DateTime.Ticks Property (System).

ticks('<timestamp>')
参数Parameter 必须Required 类型Type 说明Description
<timestamp><timestamp> Yes StringString 时间戳的字符串The string for a timestamp
返回值Return value 类型Type 说明Description
<ticks-number><ticks-number> IntegerInteger 从指定的时间戳算起已过去的时钟周期数The number of ticks since the specified timestamp

toLowertoLower

返回小写格式的字符串。Return a string in lowercase format. 如果字符串中的某个字符没有对应的小写版本,则该字符在返回的字符串中保持原样。If a character in the string doesn't have a lowercase version, that character stays unchanged in the returned string.

toLower('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要以小写格式返回的字符串The string to return in lowercase format
返回值Return value 类型Type 说明Description
<lowercase-text><lowercase-text> StringString 采用小写格式的原始字符串The original string in lowercase format

示例Example

此示例将以下字符串转换为小写:This example converts this string to lowercase:

toLower('Hello World')

并返回以下结果:"hello world"And returns this result: "hello world"

toUppertoUpper

返回大写格式的字符串。Return a string in uppercase format. 如果字符串中的某个字符没有对应的大写版本,则该字符在返回的字符串中保持原样。If a character in the string doesn't have an uppercase version, that character stays unchanged in the returned string.

toUpper('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 要以大写格式返回的字符串The string to return in uppercase format
返回值Return value 类型Type 说明Description
<uppercase-text><uppercase-text> StringString 采用大写格式的原始字符串The original string in uppercase format

示例Example

此示例将以下字符串转换为大写:This example converts this string to uppercase:

toUpper('Hello World')

并返回以下结果:"HELLO WORLD"And returns this result: "HELLO WORLD"

触发器trigger

返回触发器在运行时的输出,或者来自其他 JSON 名称和值对的值,可以将其分配给表达式。Return a trigger's output at runtime, or values from other JSON name-and-value pairs, which you can assign to an expression.

  • 在触发器的输入中,此函数返回来自上次执行的输出。Inside a trigger's inputs, this function returns the output from the previous execution.

  • 在触发器的条件中,此函数返回来自当前执行的输出。Inside a trigger's condition, this function returns the output from the current execution.

默认情况下,此函数引用整个触发器对象,但是也可以指定你需要其值的属性。By default, the function references the entire trigger object, but you can optionally specify a property whose value that you want. 此外,此函数还提供了速记版本,请参阅 triggerOutputs()triggerBody()Also, this function has shorthand versions available, see triggerOutputs() and triggerBody().

trigger()
返回值Return value 类型Type 说明Description
<trigger-output><trigger-output> StringString 触发器在运行时的输出The output from a trigger at runtime

triggerBodytriggerBody

返回触发器在运行时的 body 输出。Return a trigger's body output at runtime. trigger().outputs.body 的速记。Shorthand for trigger().outputs.body. 请参阅 trigger()See trigger().

triggerBody()
返回值Return value 类型Type 说明Description
<trigger-body-output><trigger-body-output> StringString 触发器的 body 输出The body output from the trigger

triggerFormDataMultiValuestriggerFormDataMultiValues

返回与触发器的“表单数据”或“表单编码”输出中的键名称匹配的值组成的数组。 Return an array with values that match a key name in a trigger's form-data or form-encoded output.

triggerFormDataMultiValues('<key>')
参数Parameter 必须Required 类型Type 说明Description
<key><key> Yes StringString 需要获取其值的键的名称The name for the key whose value you want
返回值Return value 类型Type 说明Description
[<array-with-key-values>][<array-with-key-values>] ArrayArray 包含与指定键匹配的所有值的数组An array with all the values that match the specified key

示例Example

此示例基于 RSS 触发器的表单数据或表单编码输出中的“feedUrl”键值创建数组:This example creates an array from the "feedUrl" key value in an RSS trigger's form-data or form-encoded output:

triggerFormDataMultiValues('feedUrl')

并将以下数组返回为示例结果:["http://feeds.reuters.com/reuters/topNews"]And returns this array as an example result: ["http://feeds.reuters.com/reuters/topNews"]

triggerFormDataValuetriggerFormDataValue

返回一个字符串,其中包含与触发器的“表单数据”或“表单编码”输出中的键名称匹配的单个值。 Return a string with a single value that matches a key name in a trigger's form-data or form-encoded output. 如果此函数找到多个匹配项,此函数将引发错误。If the function finds more than one match, the function throws an error.

triggerFormDataValue('<key>')
参数Parameter 必须Required 类型Type 说明Description
<key><key> Yes StringString 需要获取其值的键的名称The name for the key whose value you want
返回值Return value 类型Type 说明Description
<key-value><key-value> StringString 指定的键中的值The value in the specified key

示例Example

此示例基于 RSS 触发器的表单数据或表单编码输出中的“feedUrl”键值创建字符串:This example creates a string from the "feedUrl" key value in an RSS trigger's form-data or form-encoded output:

triggerFormDataValue('feedUrl')

并将以下字符串返回为示例结果:"http://feeds.reuters.com/reuters/topNews"And returns this string as an example result: "http://feeds.reuters.com/reuters/topNews"

triggerMultipartBodytriggerMultipartBody

返回具有多个部分的触发器输出中某个特定部分的正文。Return the body for a specific part in a trigger's output that has multiple parts.

triggerMultipartBody(<index>)
参数Parameter 必须Required 类型Type 说明Description
<index><index> Yes IntegerInteger 所需部分的索引值The index value for the part that you want
返回值Return value 类型Type 说明Description
<body><body> StringString 触发器多部分输出中指定部分的正文The body for the specified part in a trigger's multipart output

triggerOutputstriggerOutputs

返回触发器在运行时的输出,或者来自其他 JSON 名称和值对的值。Return a trigger's output at runtime, or values from other JSON name-and-value pairs. trigger().outputs 的速记。Shorthand for trigger().outputs. 请参阅 trigger()See trigger().

triggerOutputs()
返回值Return value 类型Type 说明Description
<trigger-output><trigger-output> StringString 触发器在运行时的输出The output from a trigger at runtime

trimtrim

从字符串中删除前导和尾随空格,并返回更新后的字符串。Remove leading and trailing whitespace from a string, and return the updated string.

trim('<text>')
参数Parameter 必须Required 类型Type 说明Description
<text><text> Yes StringString 包含要删除的前导和尾随空格的字符串The string that has the leading and trailing whitespace to remove
返回值Return value 类型Type 说明Description
<updatedText><updatedText> StringString 原始字符串的更新后版本,其中不含前导或尾随空格An updated version for the original string without leading or trailing whitespace

示例Example

此示例从字符串“Hello World”中删除前导和尾随空格:This example removes the leading and trailing whitespace from the string " Hello World ":

trim(' Hello World  ')

并返回以下结果:"Hello World"And returns this result: "Hello World"

unionunion

返回一个集合,其中包含指定集合中的所有项。Return a collection that has all the items from the specified collections. 某个项只要出现在传递给此函数的任一集合中便会出现在结果中。To appear in the result, an item can appear in any collection passed to this function. 如果一个或多个项具有相同的名称,则具有该名称的最后一项将出现在结果中。If one or more items have the same name, the last item with that name appears in the result.

union('<collection1>', '<collection2>', ...)
union([<collection1>], [<collection2>], ...)
参数Parameter 必须Required 类型Type 说明Description
<collection1>, <collection2>, ...<collection1>, <collection2>, ... Yes 数组或对象,但不能为两者Array or Object, but not both 需要从中获取所有项的各个集合The collections from where you want all the items
返回值Return value 类型Type 说明Description
<updatedCollection><updatedCollection> 分别为数组或对象Array or Object, respectively 一个集合,其中包含指定集合中的所有项 - 无重复项A collection with all the items from the specified collections - no duplicates

示例Example

此示例获取以下集合中的“所有”项:This example gets all the items from these collections:

union(createArray(1, 2, 3), createArray(1, 2, 10, 101))

并返回以下结果:[1, 2, 3, 10, 101]And returns this result: [1, 2, 3, 10, 101]

uriComponenturiComponent

通过将 URL 不安全字符替换为转义字符来返回字符串的统一资源标识符 (URI) 编码版本。Return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters. 请使用此函数而非 encodeUriComponent()Use this function rather than encodeUriComponent(). 虽然这两个函数的工作方式相同,但首选 uriComponent()Although both functions work the same way, uriComponent() is preferred.

uriComponent('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换为 URI 编码格式的字符串The string to convert to URI-encoded format
返回值Return value 类型Type 说明Description
<encoded-uri><encoded-uri> StringString 带有转义字符的 URI 编码字符串The URI-encoded string with escape characters

示例Example

此示例创建以下字符串的 URI 编码版本:This example creates a URI-encoded version for this string:

uriComponent('https://contoso.com')

并返回以下结果:"http%3A%2F%2Fcontoso.com"And returns this result: "http%3A%2F%2Fcontoso.com"

uriComponentToBinaryuriComponentToBinary

返回统一资源标识符 (URI) 组件的二进制版本。Return the binary version for a uniform resource identifier (URI) component.

uriComponentToBinary('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的 URI 编码字符串The URI-encoded string to convert
返回值Return value 类型Type 说明Description
<binary-for-encoded-uri><binary-for-encoded-uri> StringString URI 编码字符串的二进制版本。The binary version for the URI-encoded string. 二进制内容是 base64 编码的,并且由 $content 表示。The binary content is base64-encoded and represented by $content.

示例Example

此示例创建以下 URI 编码字符串的二进制版本:This example creates the binary version for this URI-encoded string:

uriComponentToBinary('http%3A%2F%2Fcontoso.com')

并返回以下结果:And returns this result:

"001000100110100001110100011101000111000000100101001100 11010000010010010100110010010001100010010100110010010001 10011000110110111101101110011101000110111101110011011011 110010111001100011011011110110110100100010"

uriComponentToStringuriComponentToString

返回统一资源标识符 (URI) 编码字符串的字符串版本,有效地对 URI 编码字符串进行解码。Return the string version for a uniform resource identifier (URI) encoded string, effectively decoding the URI-encoded string.

uriComponentToString('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要解码的 URI 编码字符串The URI-encoded string to decode
返回值Return value 类型Type 说明Description
<decoded-uri><decoded-uri> StringString URI 编码字符串的解码后的版本The decoded version for the URI-encoded string

示例Example

此示例创建以下 URI 编码字符串的解码后字符串版本:This example creates the decoded string version for this URI-encoded string:

uriComponentToString('http%3A%2F%2Fcontoso.com')

并返回以下结果:"https://contoso.com"And returns this result: "https://contoso.com"

uriHosturiHost

返回统一资源标识符 (URI) 的 host 值。Return the host value for a uniform resource identifier (URI).

uriHost('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 host 值的 URIThe URI whose host value you want
返回值Return value 类型Type 说明Description
<host-value><host-value> StringString 指定的 URI 的 hostThe host value for the specified URI

示例Example

此示例查找以下 URI 的 host 值:This example finds the host value for this URI:

uriHost('https://www.localhost.com:8080')

并返回以下结果:"www.localhost.com"And returns this result: "www.localhost.com"

uriPathuriPath

返回统一资源标识符 (URI) 的 path 值。Return the path value for a uniform resource identifier (URI).

uriPath('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 path 值的 URIThe URI whose path value you want
返回值Return value 类型Type 说明Description
<path-value><path-value> StringString 指定的 URI 的 path 值。The path value for the specified URI. 如果 path 不含值,则返回“/”字符。If path doesn't have a value, return the "/" character.

示例Example

此示例查找以下 URI 的 path 值:This example finds the path value for this URI:

uriPath('http://www.contoso.com/catalog/shownew.htm?date=today')

并返回以下结果:"/catalog/shownew.htm"And returns this result: "/catalog/shownew.htm"

uriPathAndQueryuriPathAndQuery

返回统一资源标识符 (URI) 的 pathquery 值。Return the path and query values for a uniform resource identifier (URI).

uriPathAndQuery('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 pathquery 值的 URIThe URI whose path and query values you want
返回值Return value 类型Type 说明Description
<path-query-value><path-query-value> StringString 指定的 URI 的 pathquery 值。The path and query values for the specified URI. 如果 path 未指定值,则返回“/”字符。If path doesn't specify a value, return the "/" character.

示例Example

此示例查找以下 URI 的 pathquery 值:This example finds the path and query values for this URI:

uriPathAndQuery('http://www.contoso.com/catalog/shownew.htm?date=today')

并返回以下结果:"/catalog/shownew.htm?date=today"And returns this result: "/catalog/shownew.htm?date=today"

uriPorturiPort

返回统一资源标识符 (URI) 的 port 值。Return the port value for a uniform resource identifier (URI).

uriPort('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 port 值的 URIThe URI whose port value you want
返回值Return value 类型Type 说明Description
<port-value><port-value> IntegerInteger 指定的 URI 的 port 值。The port value for the specified URI. 如果 port 未指定值,则返回协议的默认端口。If port doesn't specify a value, return the default port for the protocol.

示例Example

此示例查找以下 URI 的 port 值:This example returns the port value for this URI:

uriPort('http://www.localhost:8080')

并返回以下结果:8080And returns this result: 8080

uriQueryuriQuery

返回统一资源标识符 (URI) 的 query 值。Return the query value for a uniform resource identifier (URI).

uriQuery('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 query 值的 URIThe URI whose query value you want
返回值Return value 类型Type 说明Description
<query-value><query-value> StringString 指定的 URI 的 queryThe query value for the specified URI

示例Example

此示例查找以下 URI 的 query 值:This example returns the query value for this URI:

uriQuery('http://www.contoso.com/catalog/shownew.htm?date=today')

并返回以下结果:"?date=today"And returns this result: "?date=today"

uriSchemeuriScheme

返回统一资源标识符 (URI) 的 scheme 值。Return the scheme value for a uniform resource identifier (URI).

uriScheme('<uri>')
参数Parameter 必须Required 类型Type 说明Description
<uri><uri> Yes StringString 需要获取其 scheme 值的 URIThe URI whose scheme value you want
返回值Return value 类型Type 说明Description
<scheme-value><scheme-value> StringString 指定的 URI 的 schemeThe scheme value for the specified URI

示例Example

此示例查找以下 URI 的 scheme 值:This example returns the scheme value for this URI:

uriScheme('http://www.contoso.com/catalog/shownew.htm?date=today')

并返回以下结果:"http"And returns this result: "http"

utcNowutcNow

返回当前时间戳。Return the current timestamp.

utcNow('<format>')

另外,也可以使用 <format> 参数指定不同的格式。Optionally, you can specify a different format with the <format> parameter.

参数Parameter 必须Required 类型Type 说明Description
<format><format> No StringString 单一格式的说明符自定义格式的模式Either a single format specifier or a custom format pattern. 时间戳的默认格式为“o”(yyyy-MM-ddT:mm:ss:fffffffK),这符合 ISO 8601 标准并保留了时区信息。The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
返回值Return value 类型Type 说明Description
<current-timestamp><current-timestamp> StringString 当前日期和时间The current date and time

示例 1Example 1

假设今天的当前时间为 2018 年 4 月 15 日下午 1:00:00。Suppose today is April 15, 2018 at 1:00:00 PM. 此示例获取当前时间戳:This example gets the current timestamp:

utcNow()

并返回以下结果:"2018-04-15T13:00:00.0000000Z"And returns this result: "2018-04-15T13:00:00.0000000Z"

示例 2Example 2

假设今天的当前时间为 2018 年 4 月 15 日下午 1:00:00。Suppose today is April 15, 2018 at 1:00:00 PM. 此示例使用可选的“D”格式获取当前时间戳:This example gets the current timestamp using the optional "D" format:

utcNow('D')

并返回以下结果:"Sunday, April 15, 2018"And returns this result: "Sunday, April 15, 2018"

variablesvariables

返回指定变量的值。Return the value for a specified variable.

variables('<variableName>')
参数Parameter 必须Required 类型Type 说明Description
<variableName><variableName> Yes StringString 需要获取其值的变量的名称The name for the variable whose value you want
返回值Return value 类型Type 说明Description
<variable-value><variable-value> 任意Any 指定的变量的值The value for the specified variable

示例Example

假设“numItems”变量的当前值为 20。Suppose the current value for a "numItems" variable is 20. 此示例获取以下变量的整数值:This example gets the integer value for this variable:

variables('numItems')

并返回以下结果:20And returns this result: 20

工作流workflow

返回运行期间有关工作流本身的所有详细信息。Return all the details about the workflow itself during run time.

workflow().<property>
参数Parameter 必须Required 类型Type 说明Description
<property><property> No StringString 需要获取其值的工作流属性的名称The name for the workflow property whose value you want

工作流对象应具有以下属性:nametypeidlocationrunA workflow object has these properties: name, type, id, location, and run. run 属性值也是一个对象,它具有以下属性:nametypeidThe run property value is also an object that has these properties: name, type, and id.

示例Example

此示例返回工作流的当前运行的名称:This example returns the name for a workflow's current run:

workflow().run.name

xmlxml

返回包含 JSON 对象的字符串的 XML 版本。Return the XML version for a string that contains a JSON object.

xml('<value>')
参数Parameter 必须Required 类型Type 说明Description
<value><value> Yes StringString 要转换的包含 JSON 对象的字符串The string with the JSON object to convert

该 JSON 对象必须只有一个根属性,该属性不能是数组。The JSON object must have only one root property, which can't be an array.
请使用反斜杠字符 (\) 作为双引号 (") 的转义字符。Use the backslash character (\) as an escape character for the double quotation mark (").

返回值Return value 类型Type 说明Description
<xml-version><xml-version> ObjectObject 指定的字符串或 JSON 对象的编码 XMLThe encoded XML for the specified string or JSON object

示例 1Example 1

此示例创建包含 JSON 对象的以下字符串的 XML 版本:This example creates the XML version for this string, which contains a JSON object:

xml(json('{ \"name\": \"Sophia Owen\" }'))

并返回以下结果 XML:And returns this result XML:

<name>Sophia Owen</name>

示例 2Example 2

假设具有以下 JSON 对象:Suppose you have this JSON object:

{
  "person": {
    "name": "Sophia Owen",
    "city": "Seattle"
  }
}

此示例创建包含以下 JSON 对象的字符串的 XML:This example creates XML for a string that contains this JSON object:

xml(json('{\"person\": {\"name\": \"Sophia Owen\", \"city\": \"Seattle\"}}'))

并返回以下结果 XML:And returns this result XML:

<person>
  <name>Sophia Owen</name>
  <city>Seattle</city>
<person>

xpathxpath

检查 XML 中是否存在与 XPath(XML 路径语言)表达式匹配的节点或值,并返回匹配的节点或值。Check XML for nodes or values that match an XPath (XML Path Language) expression, and return the matching nodes or values. XPath 表达式或单纯的“XPath”有助于在 XML 文档结构中导航,以便可以在 XML 内容中选择节点或计算值。An XPath expression, or just "XPath", helps you navigate an XML document structure so that you can select nodes or compute values in the XML content.

xpath('<xml>', '<xpath>')
参数Parameter 必须Required 类型Type 说明Description
<xml><xml> Yes 任意Any 要在其中搜索与 XPath 表达式值匹配的节点或值的 XML 字符串The XML string to search for nodes or values that match an XPath expression value
<xpath><xpath> Yes 任意Any 用来查找匹配的 XML 节点或值的 XPath 表达式The XPath expression used to find matching XML nodes or values
返回值Return value 类型Type 说明Description
<xml-node><xml-node> XMLXML 一个 XML 节点,当只有单个节点与指定的 XPath 表达式匹配时An XML node when only a single node matches the specified XPath expression
<value><value> 任意Any 来自一个 XML 节点的值,当只有单个值与指定的 XPath 表达式匹配时The value from an XML node when only a single value matches the specified XPath expression
[<xml-node1>, <xml-node2>, ...][<xml-node1>, <xml-node2>, ...]
-或--or-
[<value1>, <value2>, ...][<value1>, <value2>, ...]
ArrayArray 一个数组,其中包含与指定的 XPath 表达式匹配的 XML 节点或值An array with XML nodes or values that match the specified XPath expression

示例 1Example 1

此示例查找与指定参数中的 <name></name> 节点匹配的节点,并返回包含这些节点值的数组:This example finds nodes that match the <name></name> node in the specified arguments, and returns an array with those node values:

xpath(xml(parameters('items')), '/produce/item/name')

下面是参数:Here are the arguments:

  • “items”字符串,其中包含以下 XML:The "items" string, which contains this XML:

    "<?xml version="1.0"?> <produce> <item> <name>Gala</name> <type>apple</type> <count>20</count> </item> <item> <name>Honeycrisp</name> <type>apple</type> <count>10</count> </item> </produce>"

    此示例使用 parameters() 函数从“items”参数中获取 XML 字符串,但还必须使用 xml() 函数将该字符串转换为 XML 格式。The example uses the parameters() function to get the XML string from the "items" argument, but must also convert the string to XML format by using the xml() function.

  • 以下 XPath 表达式,它是作为字符串传递的:This XPath expression, which is passed as a string:

    "/produce/item/name"

下面是结果数组,其中包含与 <name></name 匹配的节点:Here is the result array with the nodes that match <name></name:

[ <name>Gala</name>, <name>Honeycrisp</name> ]

示例 2Example 2

在示例 1 的基础上,此示例查找与 <count></count> 节点匹配的节点并通过 sum() 函数添加这些节点值:Following on Example 1, this example finds nodes that match the <count></count> node and adds those node values with the sum() function:

xpath(xml(parameters('items')), 'sum(/produce/item/count)')

并返回以下结果:30And returns this result: 30

示例 3Example 3

对于此示例,两个表达式都查找与指定参数(其中通过命名空间包括了 XML)中的 <location></location> 节点匹配的节点。For this example, both expressions find nodes that match the <location></location> node, in the specified arguments, which include XML with a namespace.

备注

如果在代码视图中操作,请使用反斜杠字符 (\) 来转义双引号 (")。If you're working in code view, escape the double quotation mark (") by using the backslash character (\). 例如,将表达式序列化为 JSON 字符串时,需要使用转义符。For example, you need to use escape characters when you serialize an expression as a JSON string. 但是,如果在逻辑应用设计器或表达式编辑器中操作,则无需转义双引号,因为反斜杠字符会自动添加到基础定义,例如:However, if you're working in the Logic App Designer or expression editor, you don't need to escape the double quotation mark because the backslash character is added automatically to the underlying definition, for example:

  • 代码视图:xpath(xml(body('Http')), '/*[name()=\"file\"]/*[name()=\"location\"]')Code view: xpath(xml(body('Http')), '/*[name()=\"file\"]/*[name()=\"location\"]')

  • 表达式编辑器:xpath(xml(body('Http')), '/*[name()="file"]/*[name()="location"]')Expression editor: xpath(xml(body('Http')), '/*[name()="file"]/*[name()="location"]')

以下示例适用于在表达式编辑器中输入的表达式。The following examples apply to expressions that you enter in the expression editor.

  • 表达式 1Expression 1

    xpath(xml(body('Http')), '/*[name()="file"]/*[name()="location"]')

  • 表达式 2Expression 2

    xpath(xml(body('Http')), '/*[local-name()="file" and namespace-uri()="http://contoso.com"]/*[local-name()="location"]')

下面是参数:Here are the arguments:

  • 以下 XML,其中包括 XML 文档命名空间 xmlns="http://contoso.com"This XML, which includes the XML document namespace, xmlns="http://contoso.com":

    <?xml version="1.0"?> <file xmlns="http://contoso.com"> <location>Paris</location> </file>
    
  • 以下任一 XPath 表达式:Either XPath expression here:

    • /*[name()="file"]/*[name()="location"]

    • /*[local-name()="file" and namespace-uri()="http://contoso.com"]/*[local-name()="location"]

下面是与 <location></location> 节点匹配的结果节点:Here is the result node that matches the <location></location> node:

<location xmlns="https://contoso.com">Paris</location>

示例 4Example 4

在示例 3 的基础上,此示例在 <location></location> 节点中查找值:Following on Example 3, this example finds the value in the <location></location> node:

xpath(xml(body('Http')), 'string(/*[name()="file"]/*[name()="location"])')

并返回以下结果:"Paris"And returns this result: "Paris"

后续步骤Next steps

了解工作流定义语言Learn about the Workflow Definition Language