Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Azure Logic Apps (Consumption + Standard)
Here are the code samples for the data operation action definitions in the article, Perform data operations. You can use these samples for when you want to try the examples with your own logic app's underlying workflow definition, Azure subscription, and API connections. Just copy and paste these action definitions into the code view editor for your logic app's workflow definition, and then modify the definitions for your specific workflow.
Based on JavaScript Object Notation (JSON) standards, these action definitions appear in alphabetical order. However, in the Logic App Designer, each definition appears in the correct sequence within your workflow because each action definition's runAfter
property specifies the run order.
To try the Compose action example, here are the action definitions you can use:
"actions": {
"Compose": {
"type": "Compose",
"inputs": {
"age": "@variables('ageVar')",
"fullName": "@{variables('lastNameVar')}, @{variables('firstNameVar')}"
},
"runAfter": {
"Initialize_variable_-_ageVar": [
"Succeeded"
]
}
},
"Initialize_variable_-_ageVar": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ageVar",
"type": "Integer",
"value": 35
}
]
},
"runAfter": {
"Initialize_variable_-_lastNameVar": [
"Succeeded"
]
}
},
"Initialize_variable_-_firstNameVar": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "firstNameVar",
"type": "String",
"value": "Sophia "
}
]
},
"runAfter": {}
},
"Initialize_variable_-_lastNameVar": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "lastNameVar",
"type": "String",
"value": "Owens"
}
]
},
"runAfter": {
"Initialize_variable_-_firstNameVar": [
"Succeeded"
]
}
}
},
To try the Create CSV table action example, here are the action definitions you can use:
"actions": {
"Create_CSV_table": {
"type": "Table",
"inputs": {
"format": "CSV",
"from": "@variables('myJSONArray')"
},
"runAfter": {
"Initialize_variable_-_JSON_array": [
"Succeeded"
]
}
},
"Initialize_variable_-_JSON_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myJSONArray",
"type": "Array",
"value": [
{
"Description": "Apples",
"Product_ID": 1
},
{
"Description": "Oranges",
"Product_ID": 2
}
]
}
]
},
"runAfter": {}
}
},
To try the Create HTML table action example, here are the action definitions you can use:
"actions": {
"Create_HTML_table": {
"type": "Table",
"inputs": {
"format": "HTML",
"from": "@variables('myJSONArray')"
},
"runAfter": {
"Initialize_variable_-_JSON_array": [
"Succeeded"
]
}
},
"Initialize_variable_-_JSON_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myJSONArray",
"type": "Array",
"value": [
{
"Description": "Apples",
"Product_ID": 1
},
{
"Description": "Oranges",
"Product_ID": 2
}
]
}
]
},
"runAfter": {}
}
},
To try the Filter array action example, here are the action definitions you can use:
"actions": {
"Filter_array": {
"type": "Query",
"inputs": {
"from": "@variables('myIntegerArray')",
"where": "@greater(item(), 1)"
},
"runAfter": {
"Initialize_variable_-_integer_array": [
"Succeeded"
]
}
},
"Initialize_variable_-_integer_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myIntegerArray",
"type": "Array",
"value": [
1,
2,
3,
4
]
}
]
},
"runAfter": {}
}
},
To try the Join action example, here are the action definitions you can use:
"actions": {
"Initialize_variable_-_integer_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myIntegerArray",
"type": "Array",
"value": [
1,
2,
3,
4
]
}
]
},
"runAfter": {}
},
"Join": {
"type": "Join",
"inputs": {
"from": "@variables('myIntegerArray')",
"joinWith": ":"
},
"runAfter": {
"Initialize_variable_-_integer_array": [
"Succeeded"
]
}
}
},
To try the Parse JSON action example, here are the action definitions you can use:
"actions": {
"Initialize_variable_-_JSON_object": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myJSONObject",
"type": "Object",
"value": {
"Member": {
"Email": "Sophia.Owens@fabrikam.com",
"FirstName": "Sophia",
"LastName": "Owens"
}
}
}
]
},
"runAfter": {}
},
"Parse_JSON": {
"type": "ParseJson",
"inputs": {
"content": "@variables('myJSONObject')",
"schema": {
"type": "object",
"properties": {
"Member": {
"type": "object",
"properties": {
"Email": {
"type": "string"
},
"FirstName": {
"type": "string"
},
"LastName": {
"type": "string"
}
}
}
}
}
},
"runAfter": {
"Initialize_variable_-_JSON_object": [
"Succeeded"
]
}
}
},
To try the Select action example, the following action definitions create a JSON object array from an integer array:
"actions": {
"Initialize_variable_-_integer_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myIntegerArray",
"type": "Array",
"value": [
1,
2,
3,
4
]
}
]
},
"runAfter": {}
},
"Select": {
"type": "Select",
"inputs": {
"from": "@variables('myIntegerArray')",
"select": {
"Product_ID": "@item()"
}
},
"runAfter": {
"Initialize_variable_-_integer_array": [
"Succeeded"
]
}
}
},
The following example shows action definitions that create a string array from a JSON object array, but for this task, next to the Map box, switch to text mode (T icon) in the designer, or use the code view editor instead:
"actions": {
"Initialize_variable_-_object_array": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "myObjectArray",
"type": "Array",
"value": [
{"Val":"1", "Txt":"One"},
{"Val":"2", "Txt":"Two"},
{"Val":"4", "Txt":"Four"},
{"Val":"10", "Txt":"Ten"}
]
}
]
},
"runAfter": {}
},
"Select": {
"type": "Select",
"inputs": {
"from": "@body('myObjectArray')?['value']",
"select": "@{item()?['Txt']}"
},
"runAfter": {
"Initialize_variable_-_object_array": [
"Succeeded"
]
}
}
},