Skip to content

Commit 4624a4e

Browse files
feat: Support Logic App Standard (#415)
Co-authored-by: Stijn Moreels <[email protected]> Co-authored-by: Pim Simons <[email protected]>
1 parent 9da6ae5 commit 4624a4e

31 files changed

+1413
-249
lines changed

docs/preview/03-Features/powershell/azure-logic-apps.md docs/preview/03-Features/powershell/azure-logic-apps-consumption.md

+46-46
Large diffs are not rendered by default.

docs/preview/03-Features/powershell/azure-logic-apps-standard.md

+354
Large diffs are not rendered by default.
Binary file not shown.

src/Arcus.Scripting.LogicApps/Arcus.Scripting.LogicApps.psm1

+34-10
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,27 @@
1010
1111
.Parameter LogicAppName
1212
The name of the Azure Logic App.
13+
14+
.Parameter WorkflowName
15+
[Optional] The name of the workflow in the Azure Logic App Standard Site.
16+
17+
.Parameter EnvironmentName
18+
[Optional] The Azure Cloud environment in which the Azure Logic App resides.
1319
1420
.Parameter MaximumFollowNextPageLink
15-
The number of times the script should retrieve the next page of Logic App runs, if not specified the entire run history of the Logic App will be retrieved.
21+
[Optional] The number of times the script should retrieve the next page of Logic App runs, if not specified the entire run history of the Logic App will be retrieved.
1622
1723
#>
1824
function Cancel-AzLogicAppRuns {
1925
param(
2026
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"),
2127
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"),
28+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
29+
[Parameter(Mandatory = $false)][string] $EnvironmentName = "AzureCloud",
2230
[Parameter(Mandatory = $false)][int] $MaximumFollowNextPageLink = 10
2331
)
2432

25-
. $PSScriptRoot\Scripts\Cancel-AzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -MaximumFollowNextPageLink $MaximumFollowNextPageLink
33+
. $PSScriptRoot\Scripts\Cancel-AzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -EnvironmentName $EnvironmentName -MaximumFollowNextPageLink $MaximumFollowNextPageLink
2634
}
2735

2836
Export-ModuleMember -Function Cancel-AzLogicAppRuns
@@ -40,29 +48,37 @@ Export-ModuleMember -Function Cancel-AzLogicAppRuns
4048
.Parameter LogicAppName
4149
The name of the Azure Logic App.
4250
51+
.Parameter WorkflowName
52+
[Optional] The name of the workflow in the Azure Logic App Standard Site.
53+
54+
.Parameter EnvironmentName
55+
[Optional] The Azure Cloud environment in which the Azure Logic App resides.
56+
4357
.Parameter StartTime
4458
The start time of the failed instances of the Azure Logic App.
4559
4660
.Parameter EndTime
47-
The end time of the failed instances of the Azure Logic App.
61+
[Optional] The end time of the failed instances of the Azure Logic App.
4862
4963
.Parameter MaximumFollowNextPageLink
50-
The number of times the script should retrieve the next page of Logic App runs, if not specified the entire run history of the Logic App will be retrieved.
64+
[Optional] The number of times the script should retrieve the next page of Logic App runs, if not specified the entire run history of the Logic App will be retrieved.
5165
5266
#>
5367
function Resubmit-FailedAzLogicAppRuns {
5468
param(
5569
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"),
5670
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"),
71+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
5772
[Parameter(Mandatory = $true)][datetime] $StartTime = $(throw "Start time is required"),
5873
[Parameter(Mandatory = $false)][datetime] $EndTime,
74+
[Parameter(Mandatory = $false)][string] $EnvironmentName = "AzureCloud",
5975
[Parameter(Mandatory = $false)][int] $MaximumFollowNextPageLink = 10
6076
)
6177

6278
if ($EndTime) {
63-
. $PSScriptRoot\Scripts\Resubmit-FailedAzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -StartTime $StartTime -EndTime $EndTime -MaximumFollowNextPageLink $MaximumFollowNextPageLink
79+
. $PSScriptRoot\Scripts\Resubmit-FailedAzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -EnvironmentName $EnvironmentName -StartTime $StartTime -EndTime $EndTime -MaximumFollowNextPageLink $MaximumFollowNextPageLink
6480
} else {
65-
. $PSScriptRoot\Scripts\Resubmit-FailedAzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -StartTime $StartTime -MaximumFollowNextPageLink $MaximumFollowNextPageLink
81+
. $PSScriptRoot\Scripts\Resubmit-FailedAzLogicAppRuns.ps1 -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -EnvironmentName $EnvironmentName -StartTime $StartTime -MaximumFollowNextPageLink $MaximumFollowNextPageLink
6682
}
6783
}
6884

@@ -86,6 +102,9 @@ Export-ModuleMember -Function Resubmit-FailedAzLogicAppRuns
86102
87103
.Parameter LogicAppName
88104
The name of the Azure Logic App to be enabled.
105+
106+
.Parameter WorkflowName
107+
[Optional] The name of the workflow in the Azure Logic App Standard Site.
89108
90109
.Parameter ApiVersion
91110
[Optional] The version of the api to be used to disable the Azure Logic App.
@@ -100,11 +119,12 @@ function Disable-AzLogicApp {
100119
[Parameter(Mandatory = $false)][string] $SubscriptionId = "",
101120
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"),
102121
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"),
122+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
103123
[Parameter(Mandatory = $false)][string] $ApiVersion = "2016-06-01",
104124
[Parameter(Mandatory = $false)][string] $AccessToken = ""
105125
)
106126

107-
. $PSScriptRoot\Scripts\Disable-AzLogicApp.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -AccessToken $AccessToken
127+
. $PSScriptRoot\Scripts\Disable-AzLogicApp.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -ApiVersion $ApiVersion -AccessToken $AccessToken
108128
}
109129

110130
Export-ModuleMember -Function Disable-AzLogicApp
@@ -123,7 +143,7 @@ Export-ModuleMember -Function Disable-AzLogicApp
123143
If your solution consists of multiple interfaces, you can specify the flow-specific name of the configuration file, if not, the script will look for a file named 'deploy-orderControl.json' by default.
124144
125145
.Parameter ResourcePrefix
126-
The prefix assigned to all Azure Logic Apps, which can differ per environment.
146+
[Optional] The prefix assigned to all Azure Logic Apps, which can differ per environment.
127147
128148
.Parameter EnvironmentName
129149
[Optional] The Azure Cloud environment in which the Azure Logic App resides.
@@ -163,6 +183,9 @@ Export-ModuleMember -Function Disable-AzLogicAppsFromConfig
163183
164184
.Parameter LogicAppName
165185
The name of the Azure Logic App to be enabled.
186+
187+
.Parameter WorkflowName
188+
[Optional] The name of the workflow in the Azure Logic App Standard Site.
166189
167190
.Parameter ApiVersion
168191
[Optional] The version of the api to be used to enable the Azure Logic App.
@@ -178,11 +201,12 @@ function Enable-AzLogicApp {
178201
[Parameter(Mandatory = $false)][string] $SubscriptionId = "",
179202
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of resource group is reqiured"),
180203
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of logic app is required"),
204+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
181205
[Parameter(Mandatory = $false)][string] $ApiVersion = "2016-06-01",
182206
[Parameter(Mandatory = $false)][string] $AccessToken = ""
183207
)
184208

185-
. $PSScriptRoot\Scripts\Enable-AzLogicApp.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -AccessToken $AccessToken
209+
. $PSScriptRoot\Scripts\Enable-AzLogicApp.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -ApiVersion $ApiVersion -AccessToken $AccessToken
186210
}
187211

188212
Export-ModuleMember -Function Enable-AzLogicApp
@@ -201,7 +225,7 @@ Export-ModuleMember -Function Enable-AzLogicApp
201225
If your solution consists of multiple interfaces, you can specify the flow-specific name of the configuration file, if not, the script will look for a file named 'deploy-orderControl.json' by default.
202226
203227
.Parameter ResourcePrefix
204-
The prefix assigned to all Azure Logic Apps, which can differ per environment.
228+
[Optional] The prefix assigned to all Azure Logic Apps, which can differ per environment.
205229
206230
.Parameter EnvironmentName
207231
[Optional] The Azure Cloud environment in which the Azure Logic App resides.

src/Arcus.Scripting.LogicApps/Arcus.Scripting.LogicApps.pssproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
<ItemGroup>
3232
<Compile Include="Arcus.Scripting.LogicApps.psd1" />
3333
<Compile Include="Arcus.Scripting.LogicApps.psm1" />
34+
<Compile Include="Scripts\Get-AzLogicAppStandardResourceManagementUrl.ps1" />
3435
<Compile Include="Scripts\Resubmit-FailedAzLogicAppRuns.ps1" />
3536
<Compile Include="Scripts\Cancel-AzLogicAppRuns.ps1" />
3637
<Compile Include="Scripts\Disable-AzLogicApp.ps1" />
3738
<Compile Include="Scripts\Disable-AzLogicAppsFromConfig.ps1" />
3839
<Compile Include="Scripts\Enable-AzLogicApp.ps1" />
3940
<Compile Include="Scripts\Enable-AzLogicAppsFromConfig.ps1" />
40-
<Compile Include="Scripts\Get-AzLogicAppResourceManagementUrl.ps1" />
41+
<Compile Include="Scripts\Get-AzLogicAppConsumptionResourceManagementUrl.ps1" />
4142
</ItemGroup>
4243
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4344
<Target Name="Build" />
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,82 @@
11
param(
22
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"),
33
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"),
4+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
5+
[Parameter(Mandatory = $false)][string] $EnvironmentName = "AzureCloud",
46
[Parameter(Mandatory = $false)][int] $MaximumFollowNextPageLink = 10
57
)
68

79
try {
8-
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName -FollowNextPageLink -MaximumFollowNextPageLink $MaximumFollowNextPageLink |
9-
Where-Object {$_.Status -eq 'Running'}
10+
if ($WorkflowName -eq "") {
11+
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName -FollowNextPageLink -MaximumFollowNextPageLink $MaximumFollowNextPageLink |
12+
Where-Object {$_.Status -eq 'Running'}
1013

11-
foreach ($run in $runs) {
12-
Stop-AzLogicAppRun -ResourceGroupName $ResourceGroupName -Name $LogicAppName -RunName $run.Name -Force
13-
Write-Verbose "Cancelled run $run.Name for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'"
14-
}
14+
foreach ($run in $runs) {
15+
$runName = $run.name
16+
Stop-AzLogicAppRun -ResourceGroupName $ResourceGroupName -Name $LogicAppName -RunName $runName -Force
17+
Write-Verbose "Cancelled run '$runName' for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'"
18+
}
19+
20+
Write-Host "Successfully cancelled all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
21+
} else {
22+
$token = Get-AzCachedAccessToken
23+
$accessToken = $token.AccessToken
24+
$subscriptionId = $token.SubscriptionId
25+
26+
$listRunningUrl = . $PSScriptRoot\Get-AzLogicAppStandardResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -Action 'listRunning'
27+
$listRunningParams = @{
28+
Method = 'Get'
29+
Headers = @{
30+
'authorization'="Bearer $accessToken"
31+
}
32+
URI = $listRunningUrl
33+
}
34+
35+
$runs = Invoke-WebRequest @listRunningParams -ErrorAction Stop
36+
$runsContent = $runs.Content | ConvertFrom-Json
37+
$allRuns = $runsContent.value
38+
39+
if ($runsContent.nextLink -ne $null) {
40+
$nextPageCounter = 1
41+
$nextPageUrl = $runsContent.nextLink
42+
while ($nextPageUrl -ne $null -and $nextPageCounter -le $MaximumFollowNextPageLink) {
43+
$nextPageCounter = $nextPageCounter + 1
44+
$listRunningParams = @{
45+
Method = 'Get'
46+
Headers = @{
47+
'authorization'="Bearer $accessToken"
48+
}
49+
URI = $nextPageUrl
50+
}
1551

16-
Write-Host "Successfully cancelled all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
52+
$runsNextPage = Invoke-WebRequest @listRunningParams -ErrorAction Stop
53+
$runsNextPageContent = $runsNextPage.Content | ConvertFrom-Json
54+
$nextPageUrl = $runsNextPageContent.nextLink
55+
$allRuns = $allRuns + $runsNextPageContent.value
56+
}
57+
}
58+
59+
foreach ($run in $allRuns) {
60+
$runName = $run.name
61+
62+
$cancelUrl = . $PSScriptRoot\Get-AzLogicAppStandardResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -RunName $runName -Action 'cancel'
63+
$cancelParams = @{
64+
Method = 'Post'
65+
Headers = @{
66+
'authorization'="Bearer $accessToken"
67+
}
68+
URI = $cancelUrl
69+
}
70+
$cancel = Invoke-WebRequest @cancelParams -ErrorAction Stop
71+
Write-Verbose "Cancelled run '$runName' for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'"
72+
}
73+
74+
Write-Host "Successfully cancelled all running instances for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
75+
}
1776
} catch {
18-
throw "Failed to cancel all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)"
77+
if ($WorkflowName -eq "") {
78+
throw "Failed to cancel all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)"
79+
} else {
80+
throw "Failed to cancel all running instances for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)"
81+
}
1982
}

src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1

+28-21
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,42 @@ param(
33
[Parameter(Mandatory = $false)][string] $SubscriptionId = "",
44
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"),
55
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"),
6+
[Parameter(Mandatory = $false)][string] $WorkflowName = "",
67
[Parameter(Mandatory = $false)][string] $ApiVersion = "2016-06-01",
78
[Parameter(Mandatory = $false)][string] $AccessToken = ""
89
)
910

1011
try{
11-
if($SubscriptionId -eq "" -or $AccessToken -eq ""){
12-
# Request accessToken in case the script contains records
13-
$token = Get-AzCachedAccessToken
12+
if ($WorkflowName -eq "") {
13+
if ($SubscriptionId -eq "" -or $AccessToken -eq "") {
14+
# Request accessToken in case the script contains records
15+
$token = Get-AzCachedAccessToken
1416

15-
$AccessToken = $token.AccessToken
16-
$SubscriptionId = $token.SubscriptionId
17-
}
17+
$AccessToken = $token.AccessToken
18+
$SubscriptionId = $token.SubscriptionId
19+
}
1820

19-
$fullUrl = . $PSScriptRoot\Get-AzLogicAppResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -Action "disable"
21+
$fullUrl = . $PSScriptRoot\Get-AzLogicAppConsumptionResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -Action "disable"
2022

21-
Write-Verbose "Attempting to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'..."
22-
$params = @{
23-
Method = 'Post'
24-
Headers = @{
25-
'authorization'="Bearer $AccessToken"
23+
Write-Verbose "Attempting to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'..."
24+
$params = @{
25+
Method = 'Post'
26+
Headers = @{
27+
'authorization'="Bearer $AccessToken"
28+
}
29+
URI = $fullUrl
2630
}
27-
URI = $fullUrl
28-
}
2931

30-
$web = Invoke-WebRequest @params -ErrorAction Stop
31-
Write-Host "Successfully disabled Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
32-
}
33-
catch {
34-
Write-Warning "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'"
35-
$ErrorMessage = $_.Exception.Message
36-
Write-Debug "Error: $ErrorMessage"
32+
$web = Invoke-WebRequest @params -ErrorAction Stop
33+
Write-Host "Successfully disabled Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
34+
} else {
35+
Set-AzAppServiceSetting -ResourceGroupName $ResourceGroupName -AppServiceName $LogicAppName -AppServiceSettingName "Workflows.$WorkflowName.FlowState" -AppServiceSettingValue "Disabled"
36+
Write-Host "Successfully disabled workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green
37+
}
38+
} catch {
39+
if ($WorkflowName -eq "") {
40+
throw "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)"
41+
} else {
42+
throw "Failed to disable workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)"
43+
}
3744
}

0 commit comments

Comments
 (0)