forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DNSHelper.psm1 - Allow for both specified DKIM selectors and MX lookup DomainAnalyser_All - Update to handle table row and return correct object - Process stored dkim selectors DomainAnalyser_GetTenantDomains - Rename from GetQueue DomainAnalyser_List - Migrate current cache files into table storage and delete - Return table storage results - Optimize the results output and reduce where-object use DomainAnalyser_Orchestrator - Import domain object to table row under TenantDetails property - Return Domain results for sending to durables ListDomainHealth - Update to store DKIM selectors when manually specified (editor/admin roles only) Scheduler_Orchestration & Standards_Orchestration - Add try/catch/finally to reduce errors in orchestrators
- Loading branch information
1 parent
1b5e5c9
commit 8bb3b5f
Showing
11 changed files
with
227 additions
and
91 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "tenant", | ||
"name": "DomainObject", | ||
"direction": "in", | ||
"type": "activityTrigger" | ||
} | ||
] | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
"direction": "in" | ||
} | ||
] | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
param($Context) | ||
|
||
New-Item "Cache_DomainAnalyser" -ItemType Directory -ErrorAction SilentlyContinue | ||
New-Item "Cache_DomainAnalyser\CurrentlyRunning.txt" -ItemType File -Force | ||
$Batch = (Invoke-ActivityFunction -FunctionName 'DomainAnalyser_GetQueue' -Input 'LetsGo') | ||
$ParallelTasks = foreach ($Item in $Batch) { | ||
Invoke-DurableActivity -FunctionName "DomainAnalyser_All" -Input $item -NoWait | ||
} | ||
try { | ||
New-Item 'Cache_DomainAnalyser' -ItemType Directory -ErrorAction SilentlyContinue | ||
New-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -ItemType File -Force | ||
|
||
$Outputs = Wait-ActivityFunction -Task $ParallelTasks | ||
Log-request -API "DomainAnalyser" -tenant $tenant -message "Outputs found count = $($Outputs.count)" -sev Info | ||
$DomainTable = Get-CippTable -Table Domains | ||
|
||
foreach ($item in $Outputs) { | ||
Write-Host $Item | Out-String | ||
$Object = $Item | ConvertTo-Json | ||
$TenantDomains = Invoke-ActivityFunction -FunctionName 'DomainAnalyser_GetTenantDomains' -Input 'Tenants' | ||
|
||
Set-Content "Cache_DomainAnalyser\$($item.domain).DomainAnalysis.json" -Value $Object -Force | ||
} | ||
# Process tenant domain results | ||
foreach ($Tenant in $TenantDomains) { | ||
$TenantDetails = $Tenant | ConvertTo-Json | ||
|
||
$ExistingDomain = @{ | ||
Table = $DomainTable | ||
rowKey = $Tenant.Domain | ||
partitionKey = $Tenant.Tenant | ||
} | ||
$Domain = Get-AzTableRow @ExistingDomain | ||
|
||
if (!$Domain) { | ||
$DomainObject = @{ | ||
Table = $DomainTable | ||
rowKey = $Tenant.Domain | ||
partitionKey = $Tenant.Tenant | ||
property = @{ | ||
DomainAnalyser = '' | ||
TenantDetails = $TenantDetails | ||
DkimSelectors = '' | ||
MailProviders = '' | ||
} | ||
} | ||
Add-AzTableRow @DomainObject | Out-Null | ||
} | ||
else { | ||
$Domain.TenantDetails = $TenantDetails | ||
$Domain | Update-AzTableRow -Table $DomainTable | Out-Null | ||
} | ||
} | ||
|
||
# Get list of all domains to process | ||
$DomainParam = @{ | ||
Table = $DomainTable | ||
} | ||
|
||
$Batch = Get-AzTableRow @DomainParam | ||
|
||
Log-request -API "DomainAnalyser" -tenant $tenant -message "Domain Analyser has Finished" -sev Info | ||
Remove-Item "Cache_DomainAnalyser\CurrentlyRunning.txt" -Force | ||
$ParallelTasks = foreach ($Item in $Batch) { | ||
Invoke-DurableActivity -FunctionName 'DomainAnalyser_All' -Input $item -NoWait | ||
} | ||
|
||
$Outputs = Wait-ActivityFunction -Task $ParallelTasks | ||
Log-request -API 'DomainAnalyser' -message "Outputs found count = $($Outputs.count)" -sev Info | ||
|
||
foreach ($DomainObject in $Outputs) { | ||
[PSCustomObject]$DomainObject | Update-AzTableRow @DomainParam | Out-Null | ||
} | ||
} | ||
catch { | ||
Log-request -API 'DomainAnalyser' -message "Domain Analyser Orchestrator Error $($_.Exception.Message)" -sev info | ||
Write-Host $_.Exception | ConvertTo-Json | ||
} | ||
finally { | ||
Log-request -API 'DomainAnalyser' -message 'Domain Analyser has Finished' -sev Info | ||
Remove-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -Force | ||
} |
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
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
Oops, something went wrong.