title | description | services | ms.suite | ms.reviewer | ms.topic | ms.date |
---|---|---|---|---|---|---|
Code samples for using data operations |
Try these code samples that show how you can use data operations in automated workflows created with Azure Logic Apps |
logic-apps |
integration |
klam, logicappspm |
conceptual |
09/01/2019 |
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": "Sophie "
}
]
},
"runAfter": {}
},
"Initialize_variable_-_lastNameVar": {
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "lastNameVar",
"type": "String",
"value": "Owen"
}
]
},
"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": "Sophie.Owen@contoso.com",
"FirstName": "Sophie",
"LastName": "Owen"
}
}
}
]
},
"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, 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": {}
},
"Select": {
"type": "Select",
"inputs": {
"from": "@variables('myIntegerArray')",
"select": {
"Product_ID": "@item()"
}
},
"runAfter": {
"Initialize_variable_-_integer_array": [
"Succeeded"
]
}
}
},