You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/add-run-csharp-scripts.md
+36-11Lines changed: 36 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,23 +39,34 @@ This guide shows how to add the action in your workflow and add the C# script co
39
39
40
40
## Considerations
41
41
42
-
- The Azure portal saves your script as a .csx file in the same folder as your **workflow.json** file, which stores the JSON definition for your workflow, and deploys the file to your logic app resource along with the workflow definition. Azure Logic Apps compiles this file to make the script ready for execution.
42
+
- The Azure portal saves your script as a C# script file (.csx) in the same folder as your **workflow.json** file, which stores the JSON definition for your workflow, and deploys the file to your logic app resource along with the workflow definition. Azure Logic Apps compiles this file to make the script ready for execution.
43
43
44
-
You can rename the .csx file for easier management during deployment. However, each time you rename the script, the new version overwrites the previous version.
44
+
The .csx file format lets you write less "boilerplate" and focus just on writing a C# function. You can rename the .csx file for easier management during deployment. However, each time you rename the script, the new version overwrites the previous version.
45
45
46
-
- The script is local to the workflow. To use the same script in other workflows, in the Kudo console, find the script file, open the shortcut menu, and then copy the script to reuse in other workflows.
46
+
- The script is local to the workflow. To use the same script in other workflows, [view the script file in the **KuduPlus** console](#view-script-file), and then copy the script to reuse in other workflows.
47
+
48
+
## Limitations
49
+
50
+
| Name | Limit | Notes |
51
+
|------|-------|-------|
52
+
| Script run duration | 10 minutes | If you have scenarios that need longer durations, use the product feedback option to provide more information abour your needs. |
53
+
| Output size | 100 MB | Output size depends on the output size limit for actions, which is generally 100 MB.
47
54
48
55
## Add the Execute CSharp Script Code action
49
56
50
-
1. In the [Azure portal](https://portal.azure.com), open your Standard workflow in the designer.
57
+
1. In the [Azure portal](https://portal.azure.com), open your Standard logic app resource and workflow in the designer.
51
58
52
59
1. In the designer, [follow these general steps to add the **Inline Code Operations** action named **Execute CSharp Script Code action** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
53
60
54
-
1. After the action information pane opens, on the **Parameters** tab, in the **Code File** box, enter your script, for example:
61
+
1. After the action information pane opens, on the **Parameters** tab, in the **Code File** box, update the prepopluated sample code with your own script code. Make sure to define the **Run** method and include any necessary assembly references and namespaces at the top of the file.
62
+
63
+
The **Run** method name is predefined, and your workflow executes only by calling this **Run** method at runtime. Data from your workflow flows into the **Run** method through the parameter that has **WorkflowContext** type. The **WorkflowContext** object not only gives your code access to outputs from the trigger, any preceding actions, and the workflow, you can also use this method to accept a function logger as a parameter and cancellation token. This token is necessary if you have a long-running script that requires graceful termination in case the function host shuts down.
64
+
65
+
The following example shows the action's **Parameters** tab with the sample script code:
55
66
56
67
:::image type="content" source="media/add-run-csharp-scripts/action-sample-script.png" alt-text="Screenshot shows Azure portal, Standard workflow designer, Request trigger, Execute CSharp Script Code action with information pane open, and Response action. Information pane shows sample C# script." lightbox="media/add-run-csharp-scripts/action-sample-script.png":::
57
68
58
-
This example continues with the following sample script code:
69
+
The following example shows the sample script code:
59
70
60
71
```csharp
61
72
// Add the required libraries.
@@ -76,7 +87,7 @@ This guide shows how to add the action in your workflow and add the C# script co
To find and view the C# script file (.csx), follow these steps:
125
+
126
+
1. In the [Azure portal](https://portal.azure.com), open your Standard logic app resource that has the workflow you want.
107
127
128
+
1. On the logic app resource menu, under **Development Tools**, select **Advanced Tools**.
108
129
109
-
## How scripting works in this scenario
130
+
1. On the **Advanced Tools** page, select **Go**, which opens the **KuduPlus** console.
110
131
111
-
The .csx format allows you to write less "boilerplate" and focus on writing just a C# function. Instead of wrapping everything in a namespace and class, just define a Run method. Include any assembly references and namespaces at the beginning of the file as usual. The name of this method is predefined, and your workflow can run only invoke this Run method at runtime.
132
+
1. Open the **Debug console** menu, and select **CMD**.
112
133
113
-
Data from your workflow flows into your Run method through parameter of WorkflowContext type. In addition to the workflow context, you can also have this method take function logger as a parameter and a cancellation tokens (needed if your script is long running and needs to be gracefully terminate in case of Function Host is shutting down).
134
+
1. Browse to the following folder location, which contains the .csx file: **site/wwwroot/{workflow-name}**
135
+
136
+
1. Next to the file name, select **Edit** to open and view the file.
114
137
115
138
## Related content
139
+
140
+
[Add and run JavaScript code snippets](add-run-javascript-code-snippets.md)
Copy file name to clipboardExpand all lines: articles/logic-apps/logic-apps-add-run-inline-code.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,7 +232,6 @@ The following table has more information about these properties:
232
232
|`actions`| Object collection | The result objects from any preceding actions that run before your code snippet runs. Each object has a *key-value* pair where the key is the action name, and the value is equivalent to the result from calling the [actions() function](workflow-definition-language-functions-reference.md#actions) with the `@actions('<action-name>')` expression. <br><br>The action's name uses the same action name that appears in the underlying workflow definition, which replaces spaces (**" "**) in the action name with underscores (**\_**). This object collection provides access to the action's property values from the current workflow instance run. |
233
233
|`trigger`| Object | The result object from the trigger where the result is the equivalent to calling the [trigger() function](workflow-definition-language-functions-reference.md#trigger). This object provides access to trigger's property values from the current workflow instance run. |
234
234
|`workflow`| Object | The workflow object that is the equivalent to calling the [workflow() function](workflow-definition-language-functions-reference.md#workflow). This object provides access to the property values, such as the workflow name, run ID, and so on, from the current workflow instance run. |
235
-
||||
236
235
237
236
In this article's example, the `workflowContext` JSON object might have the following sample properties and values from the Outlook trigger:
0 commit comments