Skip to content

Commit

Permalink
Merge pull request #1111 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
CIPP Timers and Offloaded Functions
  • Loading branch information
JohnDuprey authored Sep 6, 2024
2 parents 01685e0 + ddb3aa5 commit b9758f8
Show file tree
Hide file tree
Showing 66 changed files with 833 additions and 804 deletions.
15 changes: 0 additions & 15 deletions AddChocoApp_OrchestrationStarterTimer/function.json

This file was deleted.

7 changes: 0 additions & 7 deletions AddChocoApp_OrchestrationStarterTimer/run.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions BestPracticeAnalyser_OrchestrationStarterTimer/function.json

This file was deleted.

3 changes: 0 additions & 3 deletions BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"scriptFile": "../Modules/CippEntrypoints/CippEntrypoints.psm1",
"entryPoint": "Receive-CippTimerTrigger",
"bindings": [
{
"name": "Timer",
"schedule": "0 0 */2 * * *",
"schedule": "0 0/15 * * * *",
"direction": "in",
"type": "timerTrigger"
},
Expand Down
110 changes: 110 additions & 0 deletions CIPPTimers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[
{
"Command": "Start-UserTasksOrchestrator",
"Description": "Orchestrator to process user scheduled tasks",
"Cron": "0 */15 * * * *",
"Priority": 1,
"RunOnProcessor": true
},
{
"Command": "Start-AuditLogOrchestrator",
"Description": "Orchestrator to process audit logs",
"Cron": "0 */15 * * * *",
"Priority": 2,
"RunOnProcessor": true
},
{
"Command": "Start-WebhookOrchestrator",
"Description": "Orchestrator to process webhooks",
"Cron": "0 */15 * * * *",
"Priority": 3,
"RunOnProcessor": true
},
{
"Command": "Start-StandardsOrchestrator",
"Description": "Orchestrator to process standards",
"Cron": "0 0 */4 * * *",
"Priority": 4,
"RunOnProcessor": true
},
{
"Command": "Start-CIPPGraphSubscriptionCleanupTimer",
"Description": "Orchestrator to cleanup old Graph subscriptions",
"Cron": "0 0 0 * * *",
"Priority": 5,
"RunOnProcessor": true
},
{
"Command": "Start-SchedulerOrchestrator",
"Description": "Orchestrator to process system scheduled tasks",
"Cron": "0 0 * * * *",
"Priority": 6,
"RunOnProcessor": true
},
{
"Command": "Set-CIPPGDAPInviteGroups",
"Description": "Orchestrator to map the groups for GDAP invites",
"Cron": "0 0 */3 * * *",
"Priority": 5,
"RunOnProcessor": true
},
{
"Command": "Start-UpdateTokensTimer",
"Description": "Orchestrator to update tokens",
"Cron": "0 0 0 * * 0",
"Priority": 7,
"RunOnProcessor": true,
"IsSystem": true
},
{
"Command": "Start-CIPPGraphSubscriptionRenewalTimer",
"Description": "Orchestrator to renew Graph subscriptions",
"Cron": "0 10 * * * *",
"Priority": 8,
"RunOnProcessor": true
},
{
"Command": "Start-DomainOrchestrator",
"Description": "Orchestrator to process domains",
"Cron": "0 0 0 * * *",
"Priority": 10,
"RunOnProcessor": true
},
{
"Command": "Start-UpdatePermissionsOrchestrator",
"Description": "Orchestrator to update CPV permissions",
"Cron": "0 0 0 * * *",
"Priority": 10,
"RunOnProcessor": true,
"IsSystem": true
},
{
"Command": "Start-BillingTimer",
"Description": "Timer to process billing",
"Cron": "0 0 0 * * *",
"Priority": 12,
"RunOnProcessor": true
},
{
"Command": "Start-BPAOrchestrator",
"Description": "Orchestrator to process BPA reports",
"Cron": "0 0 3 * * *",
"Priority": 10,
"RunOnProcessor": true
},
{
"Command": "Start-ExtensionOrchestrator",
"Description": "Orchestrator to process extensions",
"Cron": "0 0 */2 * * *",
"Priority": 12,
"RunOnProcessor": true
},
{
"Command": "Start-CIPPStatsTimer",
"Description": "Timer to process CIPP stats",
"Cron": "0 0 0 * * *",
"Priority": 15,
"RunOnProcessor": true,
"IsSystem": true
}
]
15 changes: 0 additions & 15 deletions Cleanup_OldAuditLogs/function.json

This file was deleted.

9 changes: 0 additions & 9 deletions Cleanup_OldAuditLogs/run.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions Domain_OrchestrationStarterTimer/function.json

This file was deleted.

8 changes: 0 additions & 8 deletions Domain_OrchestrationStarterTimer/run.ps1

This file was deleted.

15 changes: 0 additions & 15 deletions ExecGDAPInviteApproved_Timer/function.json

This file was deleted.

5 changes: 0 additions & 5 deletions ExecGDAPInviteApproved_Timer/run.ps1

This file was deleted.

10 changes: 0 additions & 10 deletions ListGenericAllTenants/function.json

This file was deleted.

42 changes: 0 additions & 42 deletions ListGenericAllTenants/run.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,29 @@ function Push-AuditLogTenant {
StartTime = $Item.StartTime
EndTime = $Item.EndTime
}
$LogBundles = Get-CIPPAuditLogContentBundles @ContentBundleQuery
$ExistingBundles = Get-CIPPAzDataTableEntity @AuditBundleTable -Filter "PartitionKey eq '$($Item.TenantFilter)' and ContentType eq '$LogType' and Timestamp ge datetime'$($LastHour)'"
try {
$LogBundles = Get-CIPPAuditLogContentBundles @ContentBundleQuery
$ExistingBundles = Get-CIPPAzDataTableEntity @AuditBundleTable -Filter "PartitionKey eq '$($Item.TenantFilter)' and ContentType eq '$LogType' and Timestamp ge datetime'$($LastHour)'"

foreach ($Bundle in $LogBundles) {
if ($ExistingBundles.RowKey -notcontains $Bundle.contentId) {
$NewBundles.Add([PSCustomObject]@{
PartitionKey = $TenantFilter
RowKey = $Bundle.contentId
DefaultDomainName = $TenantFilter
ContentType = $Bundle.contentType
ContentUri = $Bundle.contentUri
ContentCreated = $Bundle.contentCreated
ContentExpiration = $Bundle.contentExpiration
CIPPURL = [string]$CIPPURL
ProcessingStatus = 'Pending'
MatchedRules = ''
MatchedLogs = 0
})
foreach ($Bundle in $LogBundles) {
if ($ExistingBundles.RowKey -notcontains $Bundle.contentId) {
$NewBundles.Add([PSCustomObject]@{
PartitionKey = $TenantFilter
RowKey = $Bundle.contentId
DefaultDomainName = $TenantFilter
ContentType = $Bundle.contentType
ContentUri = $Bundle.contentUri
ContentCreated = $Bundle.contentCreated
ContentExpiration = $Bundle.contentExpiration
CIPPURL = [string]$CIPPURL
ProcessingStatus = 'Pending'
MatchedRules = ''
MatchedLogs = 0
})
}
}
} catch {
Write-Information "Could not get audit log content bundles for $TenantFilter - $LogType, $($_.Exception.Message)"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ function Invoke-ExecAppUpload {
[CmdletBinding()]
param($Request, $TriggerMetadata)

try {
Start-ApplicationOrchestrator
} catch {
Write-Host "orchestrator error: $($_.Exception.Message)"
$ConfigTable = Get-CIPPTable -tablename Config
$Config = Get-CIPPAzDataTableEntity @ConfigTable -Filter "PartitionKey eq 'OffloadFunctions' and RowKey eq 'OffloadFunctions'"

if ($Config -and $Config.state -eq $true) {
if ($env:CIPP_PROCESSOR -ne 'true') {
$ProcessorFunction = [PSCustomObject]@{
FunctionName = 'CIPPFunctionProcessor'
ProcessorFunction = 'Start-ApplicationOrchestrator'
}
Push-OutputBinding -Name QueueItem -Value $ProcessorFunction
}
} else {
try {
Start-ApplicationOrchestrator
} catch {
Write-Host "orchestrator error: $($_.Exception.Message)"
}
}

$Results = [pscustomobject]@{'Results' = 'Started application queue' }
Expand Down
Loading

0 comments on commit b9758f8

Please sign in to comment.