Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIPP Timers and Offloaded Functions #1111

Merged
merged 35 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ef08fa3
Fix boolean issue with forwarding
JohnDuprey Sep 4, 2024
b74bffe
CIPP Timers and cleanup
JohnDuprey Sep 5, 2024
e643a6d
Fix CIPPtimer function
JohnDuprey Sep 5, 2024
34cfd19
Add offload function check for http trigger
JohnDuprey Sep 5, 2024
a9b1d87
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
8f67cd8
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
588cfbb
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
4b704a0
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
38b1498
update timer
JohnDuprey Sep 5, 2024
31bfb9f
stats and timer
JohnDuprey Sep 5, 2024
fb0c6e9
Update Get-CIPPTimerFunctions.ps1
JohnDuprey Sep 5, 2024
07d7085
Update Push-AuditLogTenant.ps1
JohnDuprey Sep 5, 2024
da35400
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Sep 5, 2024
b55601b
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
a926ae9
Update CippEntrypoints.psm1
JohnDuprey Sep 5, 2024
cd429b0
Update Push-AuditLogTenant.ps1
JohnDuprey Sep 5, 2024
fa1d9be
function stats
JohnDuprey Sep 5, 2024
11da714
Update Get-CIPPTimerFunctions.ps1
JohnDuprey Sep 5, 2024
58ab0b8
Fix content bundle query
JohnDuprey Sep 6, 2024
b536f29
Update Get-CIPPAuditLogContentBundles.ps1
JohnDuprey Sep 6, 2024
1675231
Add exception handling
JohnDuprey Sep 6, 2024
ff8f219
Update Push-AuditLogTenant.ps1
JohnDuprey Sep 6, 2024
4e931fe
Update Push-AuditLogTenant.ps1
JohnDuprey Sep 6, 2024
45e5551
Add status for no orchestrator run
JohnDuprey Sep 6, 2024
244e3e7
Add orchestrator rerun protection
JohnDuprey Sep 6, 2024
eb7ed9a
update logging
JohnDuprey Sep 6, 2024
7749771
Update CippEntrypoints.psm1
JohnDuprey Sep 6, 2024
8e15eb9
Queue trigger for sending commands to proc
JohnDuprey Sep 6, 2024
57c8d49
logging
JohnDuprey Sep 6, 2024
b18fdee
Update Push-CIPPFunctionProcessor.ps1
JohnDuprey Sep 6, 2024
5be7805
Update Push-CIPPFunctionProcessor.ps1
JohnDuprey Sep 6, 2024
7070d17
add processor queue logic
JohnDuprey Sep 6, 2024
e6c1aba
Migrate more functions to CIPPTimers
JohnDuprey Sep 6, 2024
9270c30
Merge remote-tracking branch 'upstream/dev' into dev
JohnDuprey Sep 6, 2024
ddb3aa5
Update CippEntrypoints.psm1
JohnDuprey Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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