Skip to content

Commit 4aa08c0

Browse files
authored
Allow Get-AzLogicAppRunHistory to return more than 30 entries (#13393)
* Fix paging * Update markdown help * Update ChangeLog.md * Removed redundant parameter set and added parameter aliases to match Invoke-RestMethod * Remove mistakenly pasted comment * Fix example * Implemented suggested changes
1 parent 7ca83a6 commit 4aa08c0

File tree

4 files changed

+76
-9
lines changed

4 files changed

+76
-9
lines changed

src/LogicApp/LogicApp/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fix for Get-AzLogicAppRunHistory only retrieving the first page of results
2122

2223
## Version 1.3.2
2324
* Update references in .psd1 to use relative path

src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.LogicApp.Cmdlets
1818
{
1919
using Microsoft.Azure.Commands.LogicApp.Utilities;
2020
using ResourceManager.Common.ArgumentCompleters;
21+
using System;
2122
using System.Management.Automation;
2223

2324
/// <summary>
@@ -45,6 +46,15 @@ public class AzureLogicAppRunHistoryCommand : LogicAppBaseCmdlet
4546
[ValidateNotNullOrEmpty]
4647
public string RunName { get; set; }
4748

49+
[Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow next page links.")]
50+
[Alias("FL")]
51+
public SwitchParameter FollowNextPageLink { get; set; }
52+
53+
[Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow next page links if FollowNextPageLink is used.")]
54+
[Alias("ML")]
55+
[ValidateRange(1, Int32.MaxValue)]
56+
public int MaximumFollowNextPageLink { get; set; } = int.MaxValue;
57+
4858
#endregion Input Parameters
4959

5060
/// <summary>
@@ -55,12 +65,19 @@ public override void ExecuteCmdlet()
5565
base.ExecuteCmdlet();
5666
if (string.IsNullOrEmpty(this.RunName))
5767
{
58-
var enumerator = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name).GetEnumerator();
59-
this.WriteObject(enumerator.ToIEnumerable<WorkflowRun>(), true);
68+
var page = new Page<WorkflowRun>();
69+
int i = 0;
70+
do
71+
{
72+
page = this.LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name, page.NextPageLink);
73+
this.WriteObject(page.GetEnumerator().ToIEnumerable<WorkflowRun>(), true);
74+
i++;
75+
}
76+
while (this.FollowNextPageLink && !string.IsNullOrWhiteSpace(page.NextPageLink) && i <= this.MaximumFollowNextPageLink);
6077
}
6178
else
6279
{
63-
this.WriteObject(LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true);
80+
this.WriteObject(this.LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true);
6481
}
6582
}
6683
}

src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ public void CancelWorkflowRun(string resourceGroupName, string workflowName,
4040
/// <param name="resourceGroupName">Name of the resource group</param>
4141
/// <param name="workflowName">Name of the workflow</param>
4242
/// <returns>List of workflow runs</returns>
43-
public Page<WorkflowRun> GetWorkflowRuns(string resourceGroupName, string workflowName)
43+
public Page<WorkflowRun> GetWorkflowRuns(string resourceGroupName, string workflowName, string nextPageLink = "")
4444
{
45-
return (Page<WorkflowRun>)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName);
45+
return string.IsNullOrWhiteSpace(nextPageLink) ?
46+
(Page<WorkflowRun>)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName) :
47+
(Page<WorkflowRun>)this.LogicManagementClient.WorkflowRuns.ListNext(nextPageLink);
4648
}
4749

4850
/// <summary>

src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.LogicApp.dll-Help.xml
33
Module Name: Az.LogicApp
44
ms.assetid: F271BCB1-6D43-48E5-BB51-00288F57BFFB
@@ -14,8 +14,8 @@ Gets the run history of a logic app.
1414
## SYNTAX
1515

1616
```
17-
Get-AzLogicAppRunHistory -ResourceGroupName <String> -Name <String> [-RunName <String>]
18-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
Get-AzLogicAppRunHistory -ResourceGroupName <String> -Name <String> [-RunName <String>] [-FollowNextPageLink]
18+
[-MaximumFollowNextPageLink <Int32>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -82,6 +82,23 @@ This command gets the run history of a logic app named LogicApp03. (autogenerate
8282
Get-AzLogicAppRunHistory -Name 'IntegrationAccount31' -ResourceGroupName MyResourceGroup
8383
```
8484

85+
### Example 4
86+
87+
This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink.
88+
89+
```powershell
90+
Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink
91+
```
92+
93+
### Example 5
94+
95+
This command gets the first two pages of run history of a logic app named LogicApp03 by following the NextPageLink and limiting the result size to two pages.
96+
Each page contains thirty results.
97+
98+
```powershell
99+
Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink -MaximumFollowNextPageLink 1
100+
```
101+
85102
## PARAMETERS
86103

87104
### -DefaultProfile
@@ -99,6 +116,36 @@ Accept pipeline input: False
99116
Accept wildcard characters: False
100117
```
101118
119+
### -FollowNextPageLink
120+
Indicates the cmdlet should follow next page links.
121+
122+
```yaml
123+
Type: System.Management.Automation.SwitchParameter
124+
Parameter Sets: (All)
125+
Aliases: FL
126+
127+
Required: False
128+
Position: Named
129+
Default value: None
130+
Accept pipeline input: False
131+
Accept wildcard characters: False
132+
```
133+
134+
### -MaximumFollowNextPageLink
135+
Specifies how many times to follow next page links if FollowNextPageLink is used.
136+
137+
```yaml
138+
Type: System.Int32
139+
Parameter Sets: (All)
140+
Aliases: ML
141+
142+
Required: False
143+
Position: Named
144+
Default value: None
145+
Accept pipeline input: False
146+
Accept wildcard characters: False
147+
```
148+
102149
### -Name
103150
Specifies the name of the logic app for which this cmdlet gets run history.
104151
@@ -146,7 +193,7 @@ Accept wildcard characters: False
146193
```
147194
148195
### CommonParameters
149-
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
196+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
150197
151198
## INPUTS
152199

0 commit comments

Comments
 (0)