diff --git a/src/LogicApp/LogicApp/ChangeLog.md b/src/LogicApp/LogicApp/ChangeLog.md index b77de82e169b..c51d6e8eca78 100644 --- a/src/LogicApp/LogicApp/ChangeLog.md +++ b/src/LogicApp/LogicApp/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Fix for Get-AzLogicAppRunHistory only retrieving the first page of results ## Version 1.3.2 * Update references in .psd1 to use relative path diff --git a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs index 8d5fa25b8419..3561de1541eb 100644 --- a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs +++ b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs @@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.LogicApp.Cmdlets { using Microsoft.Azure.Commands.LogicApp.Utilities; using ResourceManager.Common.ArgumentCompleters; + using System; using System.Management.Automation; /// @@ -45,6 +46,15 @@ public class AzureLogicAppRunHistoryCommand : LogicAppBaseCmdlet [ValidateNotNullOrEmpty] public string RunName { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow next page links.")] + [Alias("FL")] + public SwitchParameter FollowNextPageLink { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow next page links if FollowNextPageLink is used.")] + [Alias("ML")] + [ValidateRange(1, Int32.MaxValue)] + public int MaximumFollowNextPageLink { get; set; } = int.MaxValue; + #endregion Input Parameters /// @@ -55,12 +65,19 @@ public override void ExecuteCmdlet() base.ExecuteCmdlet(); if (string.IsNullOrEmpty(this.RunName)) { - var enumerator = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name).GetEnumerator(); - this.WriteObject(enumerator.ToIEnumerable(), true); + var page = new Page(); + int i = 0; + do + { + page = this.LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name, page.NextPageLink); + this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); + i++; + } + while (this.FollowNextPageLink && !string.IsNullOrWhiteSpace(page.NextPageLink) && i <= this.MaximumFollowNextPageLink); } else { - this.WriteObject(LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true); + this.WriteObject(this.LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true); } } } diff --git a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs index 63a7c5a23bab..9ce3512fd4c5 100644 --- a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs +++ b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs @@ -40,9 +40,11 @@ public void CancelWorkflowRun(string resourceGroupName, string workflowName, /// Name of the resource group /// Name of the workflow /// List of workflow runs - public Page GetWorkflowRuns(string resourceGroupName, string workflowName) + public Page GetWorkflowRuns(string resourceGroupName, string workflowName, string nextPageLink = "") { - return (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName); + return string.IsNullOrWhiteSpace(nextPageLink) ? + (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName) : + (Page)this.LogicManagementClient.WorkflowRuns.ListNext(nextPageLink); } /// diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index 54290f94b52e..e243b0f6acc9 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.PowerShell.Cmdlets.LogicApp.dll-Help.xml Module Name: Az.LogicApp ms.assetid: F271BCB1-6D43-48E5-BB51-00288F57BFFB @@ -14,8 +14,8 @@ Gets the run history of a logic app. ## SYNTAX ``` -Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] - [-DefaultProfile ] [] +Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] [-FollowNextPageLink] + [-MaximumFollowNextPageLink ] [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -82,6 +82,23 @@ This command gets the run history of a logic app named LogicApp03. (autogenerate Get-AzLogicAppRunHistory -Name 'IntegrationAccount31' -ResourceGroupName MyResourceGroup ``` +### Example 4 + +This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink. + +```powershell +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink +``` + +### Example 5 + +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. +Each page contains thirty results. + +```powershell +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink -MaximumFollowNextPageLink 1 +``` + ## PARAMETERS ### -DefaultProfile @@ -99,6 +116,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -FollowNextPageLink +Indicates the cmdlet should follow next page links. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: FL + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaximumFollowNextPageLink +Specifies how many times to follow next page links if FollowNextPageLink is used. + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: ML + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Name Specifies the name of the logic app for which this cmdlet gets run history. @@ -146,7 +193,7 @@ Accept wildcard characters: False ``` ### CommonParameters -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). +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). ## INPUTS