Skip to content

Commit 04ade59

Browse files
committed
function offloading tweaks
1 parent c0820ee commit 04ade59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ function Get-CIPPTimerFunctions {
1010

1111
# Check running nodes
1212
$VersionTable = Get-CIPPTable -tablename 'Version'
13-
$Nodes = Get-CIPPAzDataTableEntity @VersionTable -Filter "PartitionKey eq 'Version' and RowKey ne 'Version'" | Where-Object { $_.RowKey -match '-' }
14-
$AvailableNodes = $Nodes.RowKey | ForEach-Object { ($_ -split '-')[1] }
13+
$Nodes = Get-CIPPAzDataTableEntity @VersionTable -Filter "PartitionKey eq 'Version' and RowKey ne 'Version'"
14+
1515
$FunctionName = $env:WEBSITE_SITE_NAME
16+
$MainFunctionVersion = ($Nodes | Where-Object { $_.RowKey -eq $FunctionName }).Version
17+
$AvailableNodes = $Nodes.RowKey | Where-Object { $_.RowKey -match '-' -and $_.Version -eq $MainFunctionVersion } | ForEach-Object { ($_ -split '-')[1] }
1618

1719
# Get node name
1820
if ($FunctionName -match '-') {
@@ -22,7 +24,7 @@ function Get-CIPPTimerFunctions {
2224
}
2325

2426
$RunOnProcessor = $true
25-
if ($Config -and $Config.state -eq $true) {
27+
if ($Config -and $Config.state -eq $true -and $AvailableNodes.Count -gt 0) {
2628
if ($env:CIPP_PROCESSOR -ne 'true') {
2729
$RunOnProcessor = $false
2830
}

0 commit comments

Comments
 (0)