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
+63-77Lines changed: 63 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,37 +286,46 @@ To view the logs from your workflow, follow these steps:
286
286
| project TIMESTAMP, message
287
287
```
288
288
289
-
## Private modules
290
-
291
-
289
+
## Modules
292
290
293
-
## Public modules
291
+
PowerShell modules are self-contained, reusable units that include various components, for example:
294
292
295
-
You can find public modules hosted in the [PowerShell gallery](https://www.powershellgallery.com). A Standard logic app resource can support up to 10 public modules. To use any public module, you must enable this capability by following these steps, although the first step is already enabled by default:
293
+
- Cmdlets: Individual commands that perform specific tasks.
294
+
- Providers: Allow access to data stores, such as the registry or file system, as if they were drives.
295
+
- Functions: Reusable code blocks that perform specific actions.
296
+
- Variables: Store data for use within the module.
297
+
- Other types of resources.
296
298
297
-
1. opening the workflow's **host.json** file and setting the **managed dependency** property to **true**, which is enabled by default in a logic app, for example:
299
+
Modules organize and make it easier to distribute PowerShell code. You can use modules to package related functionality together, making it more manageable and shareable. The **Execute PowerShell Code** action lets you automatically import both public and private PowerShell modules.
298
300
299
-
```javascript
300
-
{
301
+
## Public modules
301
302
302
-
"managedDependency": {
303
+
To find publicly available modules, visit the [PowerShell gallery](https://www.powershellgallery.com). A Standard logic app resource can support up to 10 public modules. To use any public module, you must enable this capability by following these steps:
303
304
304
-
"enabled":true
305
+
1. In the [Azure portal](https://portal.azure.com), on your logic app resource menu, under **Development Tools**, select **Advanced Tools**.
305
306
306
-
}
307
+
1. On the **Advanced Tools** page, select **Go**.
307
308
308
-
}
309
-
```
309
+
1. On the **Kudu Plus** toolbar, from the **Debug console** menu, select **CMD**.
310
310
311
-
1.Next go to advanced tools in your logic apps panel. And go to Kudu and go to the app root level of your Logic App (C:\home\site\wwwroot). Click on the requirements.psd1 file and include the name and version of the module you are trying to reference. The supported syntax is MajorNumber.*or exact module version, as shown in the following requirements.psd1 example: Here is an example:
311
+
1.Browse to your logic app's root level at **C:\home\site\wwwroot** by using the directory structure or the command line.
312
312
313
-
@{
313
+
1. Open the workflow's **host.json** file, and set the **managed dependency** property to **true**, which should already be set by default.
314
314
315
-
Az = '1.*'
315
+
```json
316
+
"managedDependency": {
317
+
"enabled": true
318
+
}
319
+
```
316
320
317
-
SqlServer = '21.1.18147'
321
+
1. Open the file named **requirements.psd1**, and include the name and version for the module that you want to use using the following syntax: **MajorNumber.\*** or the exact module version, for example:
318
322
319
-
}
323
+
```powershell
324
+
@{
325
+
Az = '1.*'
326
+
SqlServer = '21.1.18147'
327
+
}
328
+
```
320
329
321
330
### Considerations for public modules
322
331
@@ -326,85 +335,62 @@ If you use dependency management, the following considerations apply:
326
335
327
336
- Managed dependencies currently don't support modules that require you to accept a license, either by accepting the license interactively or by providing the **-AcceptLicense** option when you run **Install-Module**.
328
337
329
-
## Compilation errors
330
-
331
-
In this release, the web-based editor includes limited IntelliSense support, which is still under improvement. Any compilation errors are detected when you save your workflow, and the Azure Logic Apps runtime compiles your script. These errors appear in your logic app's error logs.
332
-
333
-
## Runtime errors
334
-
335
-
### A workflow action doesn't return any output.
336
-
337
-
Make sure that you use **Push-WorkflowOutput**.
338
-
339
-
### Execute PowerShell Code action fails: "The term 'Hello-World' is not recognized..."
340
-
341
-
The following error happens if you incorrectly add your module to the **requirements.psd1** file or when your private module doesn't exist in the following path: **C:\home\site\wwwroot\Modules\{moduleName}.
342
-
343
-
**The term 'Hello-World' 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.**
344
-
345
-
### Execute PowerShell Code action fails: "Cannot bind argument to parameter 'Output' because it is null."
346
-
347
-
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** is null.
348
-
349
-
## WorkflowContext class
350
-
351
-
Represents a workflow context.
352
-
353
-
### Methods
354
-
355
-
#### GetActionResult(string actionName)
338
+
## Private modules
356
339
357
-
Gets the result from a specific action in the workflow.
340
+
You can generate your own private PowerShell modules. To create your first PowerShell module, see [Write a PowerShell Script Module](/powershell/scripting/developer/module/how-to-write-a-powershell-script-module).
358
341
359
-
The asynchronous version uses [**Task<>**](/dotnet/api/system.threading.tasks.task-1) as the return type, for example:
342
+
1. In the [Azure portal](https://portal.azure.com), on your logic app resource menu, under **Development Tools**, select **Advanced Tools**.
1. On the **Kudu Plus** toolbar, from the **Debug console** menu, select **CMD**.
364
347
365
-
**`actionName`**: The action name.
348
+
1. Browse to your logic app's root level at **C:\home\site\wwwroot** by using the directory structure or the command line.
366
349
367
-
##### Returns
350
+
1. Create a folder named **Modules**.
368
351
369
-
The asynchronous version returns a **`Task`**object that represents the asynchronous operation. The task result contains a **`WorkflowOperationResult`** object. For information about the **WorkflowOperationResult** object properties, see [WorkflowOperationResult class](#workflowoperationresult-class).
352
+
1. In the **Modules**folder, create a subfolder with the same name as your private module.
370
353
371
-
#### RunTriggerResult()
354
+
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.
372
355
373
-
Gets the result from the trigger in the workflow.
356
+
When you're done, your complete logic app file structure appears similar to the following example:
374
357
375
-
The asynchronous version uses [**Task<>**](/dotnet/api/system.threading.tasks.task-1) as the return type, for example:
In this release, the web-based editor includes limited IntelliSense support, which is still under improvement. Any compilation errors are detected when you save your workflow, and the Azure Logic Apps runtime compiles your script. These errors appear in your logic app's error logs.
380
376
381
-
None.
377
+
## Runtime errors
382
378
383
-
##### Returns
379
+
###A workflow action doesn't return any output.
384
380
385
-
The asynchronous version returns a **`Task`** object that represents the asynchronous operation. The task result contains a **`WorkflowOperationResult`** object. For information about the **WorkflowOperationResult** object properties, see [WorkflowOperationResult class](#workflowoperationresult-class).
381
+
Make sure that you use **Push-WorkflowOutput**.
386
382
387
-
<aname="workflowoperationresult-class"></a>
383
+
### Execute PowerShell Code action fails: "The term 'Hello-World' is not recognized..."
388
384
389
-
## WorkflowOperationResult class
385
+
If you incorrectly add your module to the **requirements.psd1** file or when your private module doesn't exist in the following path: **C:\home\site\wwwroot\Modules\{moduleName}, you get the following error:
390
386
391
-
Represents the result from a workflow operation.
387
+
**The term 'Hello-World' 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.**
392
388
393
-
### Properties
389
+
### Execute PowerShell Code action fails: "Cannot bind argument to parameter 'Output' because it is null."
394
390
395
-
| Name | Type | Description |
396
-
|------|------|-------------|
397
-
|**Name**| String | Gets or sets the operation name. |
398
-
|**Inputs**| JToken | Gets or sets the operation execution inputs. |
399
-
|**Outputs**| JToken | Gets or sets the operation execution outputs. |
400
-
|**StartTime**| DateTime? | Gets or sets the operation start time. |
401
-
|**EndTime**| DateTime? | Gets or sets the operation end time. |
402
-
|**OperationTrackingId**| String | Gets or sets the operation tracking ID. |
403
-
|**Code**| String | Gets or sets the status code for the action. |
404
-
|**Status**| String | Gets or sets the status for the action. |
405
-
|**Error**| JToken | Gets or sets the error for the action. |
406
-
|**TrackedProperties**| JToken | Gets or sets the tracked properties for the action. |
391
+
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** is null.
407
392
408
393
## Related content
409
394
410
-
[Add and run JavaScript code snippets](add-run-javascript.md)
395
+
-[Add and run JavaScript code snippets](add-run-javascript.md)
396
+
-[Add and run C# scripts](add-run-csharp-scripts.md)
0 commit comments