Skip to content

Commit f2cd6b2

Browse files
authored
Merge pull request #594 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 361f3e5 + b1b18dc commit f2cd6b2

File tree

3 files changed

+96
-15
lines changed

3 files changed

+96
-15
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Powershell project to Azure Function App - cipp65rpz
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: 'Checkout GitHub Action'
21+
uses: actions/checkout@v4
22+
23+
- name: 'Run Azure Functions Action'
24+
uses: Azure/functions-action@v1
25+
id: fa
26+
with:
27+
app-name: 'cipp65rpz'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_1A7C72E26F1D44A59F145A36961C7E14 }}
31+
sku: 'flexconsumption'
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Powershell project to Azure Function App - cippjeciy
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
workflow_dispatch:
11+
12+
env:
13+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: 'Checkout GitHub Action'
21+
uses: actions/checkout@v4
22+
23+
- name: 'Run Azure Functions Action'
24+
uses: Azure/functions-action@v1
25+
id: fa
26+
with:
27+
app-name: 'cippjeciy'
28+
slot-name: 'Production'
29+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
30+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_23DB35261CAB4B52A2CF321E5CFCCB60 }}
31+
sku: 'flexconsumption'
32+

Modules/CIPPCore/Public/AuditLogs/Get-CippAuditLogSearches.ps1

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,47 @@ function Get-CippAuditLogSearches {
1313
[Parameter()]
1414
[switch]$ReadyToProcess
1515
)
16-
$AuditLogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
17-
if ($ReadyToProcess.IsPresent) {
18-
$15MinutesAgo = (Get-Date).AddMinutes(-15).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
19-
$1DayAgo = (Get-Date).AddDays(-1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
20-
$PendingQueries = Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "PartitionKey eq 'Search' and Tenant eq '$TenantFilter' and (CippStatus eq 'Pending' or (CippStatus eq 'Processing' and Timestamp le datetime'$15MinutesAgo')) and Timestamp ge datetime'$1DayAgo'" | Sort-Object Timestamp
21-
} else {
22-
$7DaysAgo = (Get-Date).AddDays(-7).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
23-
$PendingQueries = Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "Tenant eq '$TenantFilter' and Timestamp ge datetime'$7DaysAgo'"
16+
17+
Measure-CippTask -TaskName 'GetAuditLogSearches' -EventName 'CIPP.AuditLogsProfile' -Script {
18+
$AuditLogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
19+
20+
if ($ReadyToProcess.IsPresent) {
21+
Measure-CippTask -TaskName 'QueryReadyToProcess' -EventName 'CIPP.AuditLogsProfile' -Script {
22+
$15MinutesAgo = (Get-Date).AddMinutes(-15).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
23+
$1DayAgo = (Get-Date).AddDays(-1).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
24+
Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "PartitionKey eq 'Search' and Tenant eq '$TenantFilter' and (CippStatus eq 'Pending' or (CippStatus eq 'Processing' and Timestamp le datetime'$15MinutesAgo')) and Timestamp ge datetime'$1DayAgo'" | Sort-Object Timestamp
25+
}
26+
} else {
27+
Measure-CippTask -TaskName 'QueryAllSearches' -EventName 'CIPP.AuditLogsProfile' -Script {
28+
$7DaysAgo = (Get-Date).AddDays(-7).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
29+
Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "Tenant eq '$TenantFilter' and Timestamp ge datetime'$7DaysAgo'"
30+
}
31+
}
2432
}
2533

26-
$BulkRequests = foreach ($PendingQuery in $PendingQueries) {
27-
@{
28-
id = $PendingQuery.RowKey
29-
url = 'security/auditLog/queries/' + $PendingQuery.RowKey
30-
method = 'GET'
34+
Measure-CippTask -TaskName 'BuildBulkRequests' -EventName 'CIPP.AuditLogsProfile' -Script {
35+
$BulkRequests = foreach ($PendingQuery in $PendingQueries) {
36+
@{
37+
id = $PendingQuery.RowKey
38+
url = 'security/auditLog/queries/' + $PendingQuery.RowKey
39+
method = 'GET'
40+
}
3141
}
42+
$BulkRequests
3243
}
44+
3345
if ($BulkRequests.Count -eq 0) {
3446
return @()
3547
}
36-
$Queries = New-GraphBulkRequest -Requests @($BulkRequests) -AsApp $true -TenantId $TenantFilter | Select-Object -ExpandProperty body
48+
49+
$Queries = Measure-CippTask -TaskName 'ExecuteBulkGraphRequests' -EventName 'CIPP.AuditLogsProfile' -Script {
50+
New-GraphBulkRequest -Requests @($BulkRequests) -AsApp $true -TenantId $TenantFilter | Select-Object -ExpandProperty body
51+
}
3752

3853
if ($ReadyToProcess.IsPresent) {
39-
$Queries = $Queries | Where-Object { $PendingQueries.RowKey -contains $_.id -and $_.status -eq 'succeeded' }
54+
$Queries = Measure-CippTask -TaskName 'FilterSucceededQueries' -EventName 'CIPP.AuditLogsProfile' -Script {
55+
$Queries | Where-Object { $PendingQueries.RowKey -contains $_.id -and $_.status -eq 'succeeded' }
56+
}
4057
}
4158

4259
return $Queries

0 commit comments

Comments
 (0)