Skip to content

Commit 1d9f4f9

Browse files
author
ecfan
committed
Draft
1 parent 599fbc0 commit 1d9f4f9

File tree

1 file changed

+63
-77
lines changed

1 file changed

+63
-77
lines changed

articles/logic-apps/add-run-powershell-scripts.md

Lines changed: 63 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -286,37 +286,46 @@ To view the logs from your workflow, follow these steps:
286286
| project TIMESTAMP, message
287287
```
288288

289-
## Private modules
290-
291-
289+
## Modules
292290

293-
## Public modules
291+
PowerShell modules are self-contained, reusable units that include various components, for example:
294292

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.
296298

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.
298300

299-
```javascript
300-
{
301+
## Public modules
301302

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:
303304

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**.
305306

306-
}
307+
1. On the **Advanced Tools** page, select **Go**.
307308

308-
}
309-
```
309+
1. On the **Kudu Plus** toolbar, from the **Debug console** menu, select **CMD**.
310310

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.
312312

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.
314314

315-
Az = '1.*'
315+
```json
316+
"managedDependency": {
317+
"enabled": true
318+
}
319+
```
316320

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:
318322

319-
}
323+
```powershell
324+
@{
325+
Az = '1.*'
326+
SqlServer = '21.1.18147'
327+
}
328+
```
320329

321330
### Considerations for public modules
322331

@@ -326,85 +335,62 @@ If you use dependency management, the following considerations apply:
326335

327336
- 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**.
328337

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
356339

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).
358341

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**.
360343

361-
`Task<WorkflowOperationResult> GetActionResult(string actionName)`
344+
1. On the **Advanced Tools** page, select **Go**.
362345

363-
##### Parameters
346+
1. On the **Kudu Plus** toolbar, from the **Debug console** menu, select **CMD**.
364347

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.
366349

367-
##### Returns
350+
1. Create a folder named **Modules**.
368351

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.
370353

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.
372355

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:
374357

375-
The asynchronous version uses [**Task<>**](/dotnet/api/system.threading.tasks.task-1) as the return type, for example:
358+
```text
359+
MyLogicApp
360+
- execute_powershell_script.ps1
361+
- host.json
362+
- Modules
363+
-- MyPrivateModule
364+
--- MyPrivateModule.psd1
365+
--- MyPrivateModule.psm1
366+
-- MyPrivateModule2
367+
--- MyPrivateModule2.psd1
368+
--- MyPrivateModule2.psm1
369+
- mytestworkflow.json
370+
- requirements.psd1
371+
```
376372

377-
`Task<WorkflowOperationResult> RunTriggerResult()`
373+
## Compilation errors
378374

379-
##### Parameters
375+
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.
380376

381-
None.
377+
## Runtime errors
382378

383-
##### Returns
379+
### A workflow action doesn't return any output.
384380

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**.
386382

387-
<a name="workflowoperationresult-class"></a>
383+
### Execute PowerShell Code action fails: "The term 'Hello-World' is not recognized..."
388384

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:
390386

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.**
392388

393-
### Properties
389+
### Execute PowerShell Code action fails: "Cannot bind argument to parameter 'Output' because it is null."
394390

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.
407392

408393
## Related content
409394

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

Comments
 (0)