-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from KelvinTegelaar/dev
Pushing Dev to release
- Loading branch information
Showing
53 changed files
with
1,655 additions
and
314 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
}, | ||
{ | ||
"name": "starter", | ||
"direction": "in", | ||
"type": "durableClient" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
$APIName = $TriggerMetadata.FunctionName | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug" | ||
|
||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
|
||
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value | ||
$Results = foreach ($Tenant in $tenants) { | ||
try { | ||
$CompleteObject = [PSCustomObject]@{ | ||
tenant = $tenant | ||
AdminPassword = $Request.body.AdminPassword | ||
DefenderMalware = $Request.body.DefenderMalware | ||
DefenderStatus = $Request.body.DefenderStatus | ||
DisableRestart = $Request.body.DisableRestart | ||
InstallAsSystem = $Request.body.InstallAsSystem | ||
MFAAdmins = $Request.body.MFAAdmins | ||
MFAAlertUsers = $Request.body.MFAAlertUsers | ||
NewApprovedApp = $Request.body.NewApprovedApp | ||
NewGA = $Request.body.NewGA | ||
NewRole = $Request.body.NewRole | ||
QuotaUsed = $Request.body.QuotaUsed | ||
UnusedLicenses = $Request.body.UnusedLicenses | ||
Type = "Alert" | ||
|
||
} | ConvertTo-Json | ||
$JSONFile = New-Item -Path ".\Cache_Scheduler\$tenant.alert.json" -Value $CompleteObject -Force -ErrorAction Stop | ||
"Succesfully added Alert for $($Tenant) to queue." | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Succesfully added Alert for $($Tenant) to queue." -Sev "Info" | ||
} | ||
catch { | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev "Error" | ||
"Failed to add Alert for for $($Tenant) to queue" | ||
} | ||
} | ||
|
||
$body = [pscustomobject]@{"Results" = @($results) } | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"name": "Request", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"methods": [ | ||
"post", | ||
"get" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
}, | ||
{ | ||
"name": "starter", | ||
"type": "durableClient", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using namespace System.Net | ||
|
||
param($Request, $TriggerMetadata) | ||
$CurrentlyRunning = Get-Item "ChocoApps.Cache\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" } | ||
Log-request -API "ChocoApps" -message "Attempted to start upload but an instance was already running." -sev Info | ||
} | ||
else { | ||
$InstanceId = Start-NewOrchestration -FunctionName 'Applications_Orchestrator' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId | ||
Log-request -API "ChocoApps" -message "Started uploading applications to tenants" -sev Info | ||
$Results = [pscustomobject]@{"Results" = "Started application queue" } | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) | ||
|
||
|
||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $results | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "Timer", | ||
"type": "timerTrigger", | ||
"direction": "in", | ||
"schedule": "0 0 12 * * *" | ||
}, | ||
{ | ||
"name": "starter", | ||
"type": "durableClient", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
param($Timer) | ||
|
||
$CurrentlyRunning = Get-Item "ChocoApps.Cache\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" } | ||
Log-request -API "ChocoApps" -message "Attempted to start upload but an instance was already running." -sev Info | ||
} | ||
else { | ||
$InstanceId = Start-NewOrchestration -FunctionName 'Applications_Orchestrator' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId | ||
Log-request -API "ChocoApps" -message "Started uploading applications to tenants" -sev Info | ||
$Results = [pscustomobject]@{"Results" = "Started running analysis" } | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) |
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,4 +1,4 @@ | ||
param($name) | ||
|
||
$object = (get-childitem ".\ChocoApps.Cache\*").name | ||
$object = (Get-ChildItem ".\ChocoApps.Cache\*" | Where-Object { $_.name -ne "CurrentlyRunning.txt" }).name | ||
$object |
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.