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-powershell-scripts.md
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
-
title: Add and run PowerShell in Standard workflows
2
+
title: Add and Run PowerShell in Standard Workflows
3
3
description: Write and run PowerShell script code in Standard workflows to perform custom integration tasks using Inline Code operations in Azure Logic Apps.
4
4
ms.service: azure-logic-apps
5
5
ms.suite: integration
6
6
ms.reviewer: estfan, swghimire, shahparth, azla
7
7
ms.topic: how-to
8
-
ms.date: 08/13/2024
8
+
ms.date: 05/23/2025
9
9
# Customer intent: As a logic app workflow developer, I want to write and run PowerShell code so that I can perform custom integration tasks in Standard workflows for Azure Logic Apps.
10
10
---
11
11
@@ -23,11 +23,11 @@ This capability provides the following benefits:
23
23
24
24
- Write your own scripts within the workflow designer so you can solve complex integration challenges. No other service plans are necessary.
25
25
26
-
This benefit streamlines workflow development plus reduces the complexity and cost with managing more services.
26
+
This benefit streamlines workflow development, and it reduces the complexity and cost with managing more services.
27
27
28
28
- Generate a dedicated code file, which provides a personalized scripting space within your workflow.
29
29
30
-
- Integrate with [Azure Functions PowerShell Functions](../azure-functions/functions-reference-powershell.md), which provides powerful functionality and inheritance for advanced task execution.
30
+
- Integrate with [Azure Functions PowerShell functions](../azure-functions/functions-reference-powershell.md), which provides powerful functionality and inheritance for advanced task execution.
31
31
32
32
- Deploy scripts alongside your workflows.
33
33
@@ -39,13 +39,13 @@ This guide shows how to add the action in your workflow and add the PowerShell c
39
39
40
40
* The Standard logic app workflow where you want to add your PowerShell script. The workflow must already start with a trigger. For more information, see [Create example Standard logic app workflows](create-single-tenant-workflows-azure-portal.md).
41
41
42
-
You can use any trigger for your scenario, but as an example, this guide uses the **Request** trigger named **When a HTTP request is received** and also the **Response** action. The workflow runs when another application or workflow sends a request to the trigger's endpoint URL. The sample script returns the results from code execution as output that you can use in subsequent actions.
42
+
You can use any trigger for your scenario, but as an example, this guide uses the Request trigger named **When a HTTP request is received** and also the **Response** action. The workflow runs when another application or workflow sends a request to the trigger's endpoint URL. The sample script returns the results from code execution as output that you can use in subsequent actions.
43
43
44
44
## Considerations
45
45
46
-
- The Azure portal saves your script as a PowerShell script file (.ps1) 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.
46
+
- The Azure portal saves your script as a PowerShell script file (*.ps1*) 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.
47
47
48
-
The **.ps1** file format lets you write less "boilerplate" and focus just on writing PowerShell code. If you rename the action, the file is also renamed, but not vice versa. If you directly rename the file, the renamed version overwrites the previous version. If the action name and file names don't match, the action can't find the file and tries to create a new empty file.
48
+
The *.ps1* file format lets you write less "boilerplate" and focus just on writing PowerShell code. If you rename the action, the file is also renamed, but not vice versa. If you directly rename the file, the renamed version overwrites the previous version. If the action name and file names don't match, the action can't find the file and tries to create a new empty file.
49
49
50
50
- 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.
51
51
@@ -60,7 +60,7 @@ This guide shows how to add the action in your workflow and add the PowerShell c
60
60
61
61
1. In the [Azure portal](https://portal.azure.com), open your Standard logic app resource and workflow in the designer.
62
62
63
-
1. In the designer, [follow these general steps to add the **Inline Code Operations** action named **Execute PowerShell Code** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
63
+
1. In the designer, add the **Inline Code Operations** action named **Execute PowerShell Code** to your workflow. For detailed steps, see [Add an action to run a task](add-trigger-action-workflow.md?tabs=standard#add-action).
64
64
65
65
1. After the action information pane opens, on the **Parameters** tab, in the **Code File** box, update the prepopulated sample code with your own code.
66
66
@@ -107,7 +107,7 @@ After you run your workflow, you can review the workflow output in Application I
107
107
108
108
## Access workflow trigger and action outputs in your script
109
109
110
-
The output values from the trigger and preceding actions are returned using a custom object, which has multiple parameters. To access these outputs and make sure that you return the value that you want, use the [**Get-TriggerOutput**](#get-triggeroutput), [**Get-ActionOutput**](#get-actionoutput), and [**Push-WorkflowOutput**](#push-workflowoutput) cmdlets plus any appropriate parameters described in the following table, for example:
110
+
The output values from the trigger and preceding actions are returned using a custom object, which has multiple parameters. To access these outputs and make sure that you return the value that you want, use the [Get-TriggerOutput](#get-triggeroutput), [Get-ActionOutput](#get-actionoutput), and [Push-WorkflowOutput](#push-workflowoutput) cmdlets plus any appropriate parameters described in the following table, for example:
> In PowerShell, if you reference an object that has **JValue** type inside a complex object, and you
125
-
> add that object to a string, you get a format exception. To avoid this error, use **ToString()**.
124
+
> In PowerShell, if you reference an object that has *JValue* type inside a complex object, and you
125
+
> add that object to a string, you get a format exception. To avoid this error, use `ToString()`.
126
126
127
127
### Trigger and action response outputs
128
128
129
-
The following table lists the outputs that are generated when you call **Get-ActionOutput** or **Get-TriggerOutput**. The return value is a complex object called **PowershellWorkflowOperationResult**, which contains thee following outputs.
129
+
The following table lists the outputs that are generated when you call `Get-ActionOutput` or `Get-TriggerOutput`. The return value is a complex object called `PowershellWorkflowOperationResult`, which contains the following outputs.
130
130
131
131
| Name | Type | Description |
132
132
|------|------|-------------|
133
-
|**Name**| String | The name for the trigger or action.|
134
-
|**Inputs**| JToken | The input values passed into the trigger or action.|
135
-
|**Outputs**| JToken | The outputs from the executed trigger or action.|
136
-
|**StartTime**| DateTime | The start time for the trigger or action.|
137
-
|**EndTime**| DateTime | The end time for the trigger or action.|
138
-
|**ScheduledTime**| DateTime | The scheduled time to run the trigger or action or trigger.|
139
-
|**OriginHistoryName**| String | The origin history name for triggers with the **Split-On** option enabled.|
140
-
|**SourceHistoryName**| String | The source history name for a resubmitted trigger.|
141
-
|**TrackingId**| String | The operation tracking ID.|
142
-
|**Code**| String | The status code for the result.|
143
-
|**Status**| String | The run status for the trigger or action, for example, **Succeeded** or **Failed**.|
144
-
|**Error**| JToken | The HTTP error code.|
145
-
|**TrackedProperties**| JToken | Any tracked properties that you set up.|
133
+
|**Name**| String | The name for the trigger or action |
134
+
|**Inputs**| JToken | The input values passed into the trigger or action |
135
+
|**Outputs**| JToken | The outputs from the executed trigger or action |
136
+
|**StartTime**| DateTime | The start time for the trigger or action |
137
+
|**EndTime**| DateTime | The end time for the trigger or action |
138
+
|**ScheduledTime**| DateTime | The scheduled time to run the trigger or action or trigger |
139
+
|**OriginHistoryName**| String | The origin history name for triggers with the `SplitOn` option enabled |
140
+
|**SourceHistoryName**| String | The source history name for a resubmitted trigger |
141
+
|**TrackingId**| String | The operation tracking ID |
142
+
|**Code**| String | The status code for the result |
143
+
|**Status**| String | The run status for the trigger or action, for example, "Succeeded" or "Failed"|
144
+
|**Error**| JToken | The HTTP error code |
145
+
|**TrackedProperties**| JToken | Any tracked properties that you set up |
146
146
147
147
<aname="return-data-to-workflow"></a>
148
148
149
149
## Return outputs to your workflow
150
150
151
-
To return any outputs to your workflow, you must use the [**Push-WorkflowOutput** cmdlet](#push-workflowoutput).
151
+
To return any outputs to your workflow, you must use the [Push-WorkflowOutput cmdlet](#push-workflowoutput).
152
152
153
153
## Custom PowerShell commands
154
154
@@ -170,7 +170,7 @@ None.
170
170
171
171
### Get-ActionOutput
172
172
173
-
Gets the output from another action in the workflow and returns an object named **PowershellWorkflowOperationResult**.
173
+
Gets the output from another action in the workflow and returns an object named `PowershellWorkflowOperationResult`.
174
174
175
175
#### Syntax
176
176
@@ -190,8 +190,8 @@ Pushes output from the **Execute PowerShell Code** action to your workflow, whic
190
190
191
191
> [!NOTE]
192
192
>
193
-
> The **Write-Debug**, **Write-Host**, and **Write-Output** cmdlets don't return values
194
-
> to your workflow. The **return** statement also doesn't return values to your workflow.
193
+
> The `Write-Debug`, `Write-Host`, and `Write-Output` cmdlets don't return values
194
+
> to your workflow. The `return` statement also doesn't return values to your workflow.
195
195
> However, you can use these cmdlets to write trace messages that appear in Application Insights.
196
196
> For more information, see [Microsoft.PowerShell.Utility](/powershell/module/microsoft.powershell.utility).
|**Output**| Varies.| The output that you want to return to the workflow. This output can have any type. |
209
-
|**Clobber**| Varies.| An optional switch parameter that you can use to override the previously pushed output. |
208
+
|**Output**| Varies | The output that you want to return to the workflow. This output can have any type. |
209
+
|**Clobber**| Varies | An optional switch parameter that you can use to override the previously pushed output. |
210
210
211
211
## Authenticate and authorize access with a managed identity using PowerShell
212
212
@@ -216,7 +216,7 @@ From inside the **Execute PowerShell Code** action, you can authenticate and aut
216
216
217
217
To use the managed identity from inside the **Execute PowerShell Code** action, you must follow these steps:
218
218
219
-
1.[Follow these steps to set up the managed identity on your logic app and grant the managed identity access on the target Azure resource](authenticate-with-managed-identity.md?tabs=standard).
219
+
1.Set up the managed identity on your logic app and grant the managed identity access on the target Azure resource. To learn how, see [Authenticate access and connections to Azure resources with managed identities](authenticate-with-managed-identity.md?tabs=standard).
220
220
221
221
On the target Azure resource, review the following considerations:
222
222
@@ -248,15 +248,15 @@ To use the managed identity from inside the **Execute PowerShell Code** action,
248
248
249
249
1. Go to your logic app's root location: **site/wwwroot**
250
250
251
-
1. Go to your workflow's folder, which contains the .ps1 file, along this path: **site/wwwroot/{workflow-name}**
251
+
1. Go to your workflow's folder, which contains the *.ps1* file, along this path: **site/wwwroot/{workflow-name}**
252
252
253
253
1. Next to the file name, select **Edit** to open and view the file.
254
254
255
255
<aname="log-output-application-insights"></a>
256
256
257
257
## View logs in Application Insights
258
258
259
-
1. In the [Azure portal](https://portal.azure.com), on the logic app resource menu, under **Settings**, select **Application Insights**, and then select your logic app.
259
+
1. In the [Azure portal](https://portal.azure.com), under **Monitoring**on the logic app resource menu, select **Application Insights**, and then select your logic app.
260
260
261
261
1. On the **Application Insights** menu, under **Monitoring**, select **Logs**.
262
262
@@ -299,7 +299,7 @@ To find publicly available modules, visit the [PowerShell gallery](https://www.p
299
299
}
300
300
```
301
301
302
-
1. Open the file named **requirements.psd1**. Include the name and version for the module that you want by using the following syntax: **MajorNumber.\*** or the exact module version, for example:
302
+
1. Open the file named **requirements.psd1**. Include the name and version for the module that you want by using the following syntax: `MajorNumber.*` or the exact module version, for example:
303
303
304
304
```powershell
305
305
@{
@@ -332,7 +332,7 @@ You can generate your own private PowerShell modules. To create your first Power
332
332
333
333
1. In the **Modules** folder, create a subfolder with the same name as your private module.
334
334
335
-
1. In your private module folder, add your private PowerShell module file with the **psm1** file name extension. You can also include an optional PowerShell manifest file with the **psd1** file name extension.
335
+
1. In your private module folder, add your private PowerShell module file with the *psm1* file name extension. You can also include an optional PowerShell manifest file with the *psd1* file name extension.
336
336
337
337
When you're done, your complete logic app file structure appears similar to the following example:
338
338
@@ -359,13 +359,13 @@ In this release, the web-based editor includes limited IntelliSense support, whi
359
359
360
360
### A workflow action doesn't return any output.
361
361
362
-
Make sure that you use the **Push-WorkflowOutput** cmdlet.
362
+
Make sure that you use the `Push-WorkflowOutput` cmdlet.
363
363
364
364
### Execute PowerShell Code action fails: "The term '{some-text}' is not recognized..."
365
365
366
366
If you incorrectly reference a public module in the **requirements.psd1** file or when your private module doesn't exist in the following path: **C:\home\site\wwwroot\Modules\{module-name}**, you get the following error:
367
367
368
-
**The term '{some-text}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name or if a path was included, verify the path is correct and try again.**
368
+
**"The term '{some-text}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name or if a path was included, verify the path is correct and try again."**
369
369
370
370
> [!NOTE]
371
371
>
@@ -374,7 +374,7 @@ If you incorrectly reference a public module in the **requirements.psd1** file o
374
374
375
375
### Execute PowerShell Code action fails: "Cannot bind argument to parameter 'Output' because it is null."
376
376
377
-
This error happens when you try to push a null object to the workflow. Confirm whether the object that you're sending with **Push-WorkflowOutput** isn't null.
377
+
This error happens when you try to push a null object to the workflow. Confirm whether the object that you're sending with `Push-WorkflowOutput` isn't null.
0 commit comments