Last active
July 25, 2020 10:51
-
-
Save MateuszNad/9d2b7df764b1126fb6c65dfec9df5eb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
https://azure.microsoft.com/en-us/pricing/details/logic-apps/ | |
Actions $0.000025 | |
Standard Connector $0.000125 | |
Enterprise Connector $0.001 | |
.EXAMPLE | |
Get-LogicAppEstimatedCost -Path C:\Temp\logicapp.json | |
Object Name Type Cost | |
------ ---- ---- ---- | |
connector azureblob_1 0,000125 | |
connector azureeventgrid_1 0,000125 | |
connector azuretables_1 0,000125 | |
connector cognitiveservicescomputervision_1 0,000125 | |
action Copy_blob ApiConnection 2,5E-05 | |
action Create_SAS_for_photo ApiConnection 2,5E-05 | |
action Create_SAS_for_thumbnail ApiConnection 2,5E-05 | |
action Delay Wait 2,5E-05 | |
action Get_Blob_Metadata ApiConnection 2,5E-05 | |
action Until Until 2,5E-05 | |
action Check_contentLength If 2,5E-05 | |
action Compose Compose 2,5E-05 | |
action Delete_blob_from_temp ApiConnection 2,5E-05 | |
action Delete_blob_from_thumbnail ApiConnection 2,5E-05 | |
action HTTP Http 2,5E-05 | |
action Insert_Entity ApiConnection 2,5E-05 | |
action Parse_DataObject_from_Event ParseJson 2,5E-05 | |
action Append_to_array_variable AppendToArrayVariable 2,5E-05 | |
action SplitedTags_-_add_value Foreach 2,5E-05 | |
action SplitedTags_-_variable InitializeVariable 2,5E-05 | |
action Tag_Image ApiConnection 2,5E-05 | |
.EXAMPLE | |
Get-LogicAppEstimatedCost -Path C:\Temp\logicapp.json -CountOfActionCycle 20 | |
Object Name Type Cost | |
----- ---- ---- ---- | |
... | |
action SplitedTags_-_variable InitializeVariable 2,5E-05 | |
action Tag_Image ApiConnection 2,5E-05 | |
actionCycle actionCycle * 20 0,0005 | |
For actions that run inside loops, Azure Logic Apps counts each action for each cycle in the loop. For example, suppose you have a "for each" loop that processes a list. Logic Apps meters an action in that loop by multiplying the number of list items with the number of actions in the loop, and adds the action that starts the loop. So, the calculation for a 10-item list is (10 * 1) + 1, which results in 11 action executions. | |
.EXAMPLE | |
Get-LogicAppEstimatedCost -Path C:\Temp\logicapp.json | Measure-Object -Property Cost -Sum | |
Count : 21 | |
Average : | |
Sum : 0,000924999999999999 | |
Maximum : | |
Minimum : | |
Property : Cost | |
.EXAMPLE | |
(Get-LogicAppEstimatedCost -Path C:\Temp\logicapp.json | Measure-Object -Property Cost -Sum).Sum * 100000 | |
92,4999999999999 | |
The estimated cost of the "Logic App" if will be run 10000 times. | |
#> | |
function Get-LogicAppEstimatedCost | |
{ | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
$Path, | |
# https://docs.microsoft.com/pl-pl/azure/logic-apps/logic-apps-pricing#actions | |
[Parameter()] | |
[int]$CountOfActionCycle | |
) | |
begin | |
{ | |
function Get-LogicAppConnection | |
{ | |
[cmdletbinding()] | |
param( | |
[Parameter(ValueFromPipeline)] | |
$InputObject | |
) | |
process | |
{ | |
$ConnectionsName = ($InputObject | Get-Member -MemberType NoteProperty).Name | |
foreach ($ConnectionName in $ConnectionsName) | |
{ | |
# $InputObject.$ConnectionName | fl | |
Write-Verbose "Logic App Connector Name`:$ConnectionName" | |
[PSCustomObject]@{ | |
Object = 'connector' | |
Name = $ConnectionName | |
Type = '' | |
Cost = 0.000125 | |
} | |
} | |
} | |
} | |
function Get-LogicAppAction | |
{ | |
[cmdletbinding()] | |
param( | |
[Parameter(ValueFromPipeline)] | |
$InputObject | |
) | |
process | |
{ | |
$ActionsName = ($InputObject | Get-Member -MemberType NoteProperty).Name | |
foreach ($ActionName in $ActionsName) | |
{ | |
#$InputObject.$ActionName | |
Write-Verbose "Logic App Action Name`:$ActionName" | |
if ($InputObject.$ActionName.actions) | |
{ | |
Get-Action -InputObject $InputObject.$ActionName.actions | |
} | |
[PSCustomObject]@{ | |
Object = 'action' | |
Name = $ActionName | |
Type = $InputObject.$ActionName.Type | |
Cost = 0.000025 | |
} | |
} | |
} | |
} | |
} | |
process | |
{ | |
Write-Warning "The function can't recognize the difference between Standard and Enterprise connector therefore cost of Logic App can be not accurate." | |
$LogicAppCode = Get-Content -Path $Path | ConvertFrom-Json | |
$Actions = $LogicAppCode.Definition.actions | |
$Connection = $LogicAppCode.parameters.'$connections'.value | |
Get-Connection -InputObject $Connection | |
Get-Action -InputObject $Actions | |
if ($CountOfActionCycle -gt 0) | |
{ | |
[PSCustomObject]@{ | |
Object = 'actionCycle' | |
Name = "actionCycle * $CountOfActionCycle" | |
Type = '' | |
Cost = (0.000025 * $CountOfActionCycle) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment