-
-
Save MateuszNad/36d9f449090ea00f8b71a531409c7034 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 -LogicAppCode (Get-Content -Path C:\Temp\logfile.txt) | Format-Table -AutoSize | |
Object Name Type Cost | |
------ ---- ---- ---- | |
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 -LogicAppCode (Get-Content -Path C:\Temp\logfile.txt) | Measure-Object -Property Cost -Sum | |
Count : 25 | |
Average : | |
Sum : 0,002 | |
Maximum : | |
Minimum : | |
Property : Cost | |
.EXAMPLE | |
(Get-LogicAppEstimatedCost -LogicAppCode (Get-Content -Path C:\Temp\logfile.txt) | Measure-Object -Property Cost -Sum).Sum * 100000 | |
92,4999999999999 | |
The estimated cost of the "Logic App" if will be run 10000 times. | |
#> | |
function Get-LogicAppAction | |
{ | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory)] | |
$InputObject, | |
[Parameter(Mandatory = $false)] | |
$ConnectorInputObject | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
$ActionsName = ($InputObject | Get-Member -MemberType NoteProperty).Name | |
$Object = 'action' | |
foreach ($ActionName in $ActionsName) | |
{ | |
#$InputObject.$ActionName | |
Write-Verbose "Logic App Action Name`:$ActionName" | |
if ($InputObject.$ActionName.actions) | |
{ | |
Get-LogicAppAction -InputObject $InputObject.$ActionName.actions -ConnectorInputObject $ConnectorInputObject | |
} | |
if ($InputObject.$ActionName.Type -eq 'ApiConnection') | |
{ | |
$ConnectorName = $InputObject.$ActionName.inputs.host.connection.name | |
$Cost = 0.000150 | |
foreach ($Connector in $ConnectorInputObject) | |
{ | |
if ($InputObject.$ActionName.inputs.host.connection.name -match $Connector.Name) | |
{ | |
$ConnectorName = $Connector.Name | |
$Cost = $Connector.Cost | |
$Object = 'connector' | |
} | |
} | |
} | |
else | |
{ | |
$ConnectorName = '' | |
$Cost = 0.000025 | |
} | |
[PSCustomObject]@{ | |
Object = $Object | |
Name = $ActionName | |
Type = $InputObject.$ActionName.Type | |
ConnectionName = $ConnectorName | |
Cost = $Cost | |
} | |
} | |
} | |
} | |
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-LogicAppEstimatedCost | |
{ | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
$LogicAppCode | |
# https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-pricing | |
) | |
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 = $LogicAppCode | ConvertFrom-Json | |
# $LogicAppCode = Get-Content -Path $Path | ConvertFrom-Json | |
$Actions = $LogicAppCode.Definition.actions | |
$Connection = $LogicAppCode.parameters.'$connections'.value | |
# Get-LogicAppConnection -InputObject $Connection | |
$Result = Get-LogicAppAction -InputObject $Actions -ConnectorInputObject (Get-LogicAppConnection -InputObject $Connection) | |
Write-Output $Result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment