Skip to content

Commit

Permalink
Merge branch 'KelvinTegelaar:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dsghi authored May 6, 2024
2 parents f38b29f + 3371bf5 commit 64502a6
Show file tree
Hide file tree
Showing 249 changed files with 4,340 additions and 1,775 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/dev_cippeln4y.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cippeln4y

on:
push:
branches:
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
deploy:
runs-on: windows-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cippeln4y'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B82C66E0F3BD4BDD9FFFB32FA83A68C9 }}
9 changes: 0 additions & 9 deletions BestPracticeAnalyser_All/function.json

This file was deleted.

9 changes: 0 additions & 9 deletions BestPracticeAnalyser_GetQueue/function.json

This file was deleted.

10 changes: 0 additions & 10 deletions BestPracticeAnalyser_GetQueue/run.ps1

This file was deleted.

9 changes: 0 additions & 9 deletions BestPracticeAnalyser_Orchestration/function.json

This file was deleted.

21 changes: 0 additions & 21 deletions BestPracticeAnalyser_Orchestration/run.ps1

This file was deleted.

46 changes: 33 additions & 13 deletions BestPracticeAnalyser_OrchestrationStarter/run.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
using namespace System.Net

param($Request, $TriggerMetadata)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' }
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info

if ($Request.Query.TenantFilter) {
$TenantList = @($Request.Query.TenantFilter)
$Name = "Best Practice Analyser ($($Request.Query.TenantFilter))"
} else {
$InputObject = @{
TenantFilter = $Request.Query.TenantFilter
$TenantList = Get-Tenants
$Name = 'Best Practice Analyser (All Tenants)'
}
$CippRoot = (Get-Item $PSScriptRoot).Parent.FullName
$TemplatesLoc = Get-ChildItem "$CippRoot\Config\*.BPATemplate.json"
$Templates = $TemplatesLoc | ForEach-Object {
$Template = $(Get-Content $_) | ConvertFrom-Json
$Template.Name
}

$BPAReports = foreach ($Tenant in $TenantList) {
foreach ($Template in $Templates) {
[PSCustomObject]@{
FunctionName = 'BPACollectData'
Tenant = $Tenant.defaultDomainName
Template = $Template
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName
}
}
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration' -InputObject $InputObject
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info
$Results = [pscustomobject]@{'Results' = 'Started running analysis' }
}
Write-Host ($Orchestrator | ConvertTo-Json)

$Queue = New-CippQueueEntry -Name $Name -TotalTasks ($BPAReports | Measure-Object).Count
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } }
$InputObject = [PSCustomObject]@{
Batch = @($BPAReports)
OrchestratorName = 'BPAOrchestrator'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)

$Results = [pscustomobject]@{'Results' = 'BPA started' }
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $results
Body = $Results
})
45 changes: 29 additions & 16 deletions BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
param($Timer)

if ($env:DEV_SKIP_BPA_TIMER) {
if ($env:DEV_SKIP_BPA_TIMER) {
Write-Host 'Skipping BPA timer'
exit 0
exit 0
}

try {
$CurrentlyRunning = Get-Item 'Cache_BestPracticeAnalyser\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' }
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info
$Results = [pscustomobject]@{'Results' = 'Started running analysis' }
$TenantList = Get-Tenants

$CippRoot = (Get-Item $PSScriptRoot).Parent.FullName
$TemplatesLoc = Get-ChildItem "$CippRoot\Config\*.BPATemplate.json"
$Templates = $TemplatesLoc | ForEach-Object {
$Template = $(Get-Content $_) | ConvertFrom-Json
$Template.Name
}

$BPAReports = foreach ($Tenant in $TenantList) {
foreach ($Template in $Templates) {
[PSCustomObject]@{
FunctionName = 'BPACollectData'
Tenant = $Tenant.defaultDomainName
Template = $Template
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName
}
}
Write-Host ($Orchestrator | ConvertTo-Json)
}
catch { Write-Host "BestPracticeAnalyser_OrchestratorStarterTimer Exception $($_.Exception.Message)" }

$Queue = New-CippQueueEntry -Name 'Best Practice Analyser' -TotalTasks ($BPAReports | Measure-Object).Count
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } }
$InputObject = [PSCustomObject]@{
Batch = @($BPAReports)
OrchestratorName = 'BPAOrchestrator'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)
33 changes: 33 additions & 0 deletions Config/CIPPTenantFeatures.BPATemplate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "CIPP Tenant Feature Licensing",
"style": "Table",
"Fields": [
{
"name": "AssignedPlans",
"UseExistingInfo": false,
"ExtractFields": ["AADPremiumService", "exchange", "SharePoint"],
"FrontendFields": [
{
"name": "Entra ID Premium",
"value": "AssignedPlans.AADPremiumService",
"formatter": "bool"
},
{
"name": "Exchange",
"value": "AssignedPlans.exchange",
"formatter": "bool"
},
{
"name": "SharePoint",
"value": "AssignedPlans.SharePoint",
"formatter": "bool"
}
],
"desc": "Entra ID Premium Status",
"StoreAs": "JSON",
"API": "CIPPFunction",
"Command": "Get-CIPPTenantCapabilities",
"Parameters": {}
}
]
}
6 changes: 5 additions & 1 deletion DomainAnalyser_OrchestrationStarter/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ using namespace System.Net
param($Request, $TriggerMetadata)

$Results = [pscustomobject]@{'Results' = 'Domain Analyser started' }
$TenantList = Get-Tenants -IncludeAll
$Queue = New-CippQueueEntry -Name 'Domain Analyser' -TotalTasks ($TenantList | Measure-Object).Count
$InputObject = [PSCustomObject]@{
QueueFunction = [PSCustomObject]@{
FunctionName = 'GetTenants'
DurableName = 'DomainAnalyserTenant'
DurableName = 'DomainAnalyserTenant'
QueueId = $Queue.RowKey
TenantParams = @{
IncludeAll = $true
}
}
OrchestratorName = 'DomainAnalyser_Tenants'
SkipLog = $true
DurableMode = 'Sequence'
}
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5)

Expand Down
3 changes: 3 additions & 0 deletions Domain_OrchestrationStarterTimer/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ try {
Write-LogMessage -API 'DomainAnalyser' -message 'Starting Domain Analyser' -sev Info
$Results = [pscustomobject]@{'Results' = 'Starting Domain Analyser' }

$TenantList = Get-Tenants -IncludeAll
$Queue = New-CippQueueEntry -Name 'Domain Analyser' -TotalTasks ($TenantList | Measure-Object).Count
$InputObject = [PSCustomObject]@{
QueueFunction = [PSCustomObject]@{
FunctionName = 'GetTenants'
DurableName = 'DomainAnalyserTenant'
QueueId = $Queue.RowKey
TenantParams = @{
IncludeAll = $true
}
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
@{
# Version number of this module.
ModuleVersion = '1.1.0'

# Supported PSEditions
CompatiblePSEditions = @('Core')

# ID used to uniquely identify this module
GUID = '841fad61-94f5-4330-89be-613d54165289'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = '(c) Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Initial release of the Durable Functions SDK for PowerShell. This package is to be used exclusively with the Azure Functions PowerShell worker.'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '7.2'

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @() # TODO: use this for pretty-printing DF tasks

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @() # TODO: use this for pretty-printing DF tasks

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('./AzureFunctions.PowerShell.Durable.SDK.dll', './AzureFunctions.PowerShell.Durable.SDK.psm1')

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Get-DurableStatus',
'New-DurableOrchestrationCheckStatusResponse',
'Send-DurableExternalEvent',
'Start-DurableOrchestration',
'Stop-DurableOrchestration',
'Suspend-DurableOrchestration',
'Resume-DurableOrchestration'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @(
'Invoke-DurableActivity',
'Invoke-DurableSubOrchestrator',
'New-DurableRetryPolicy',
'Set-DurableCustomStatus',
'Set-FunctionInvocationContext',
'Start-DurableExternalEventListener'
'Start-DurableTimer',
'Stop-DurableTimerTask',
'Wait-DurableTask',
'Get-DurableTaskResult'
)

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @(
'Invoke-ActivityFunction',
'New-OrchestrationCheckStatusResponse',
'Start-NewOrchestration',
'Wait-ActivityFunction',
'New-DurableRetryOptions'
)

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('Microsoft', 'Azure', 'Functions', 'Serverless', 'Cloud', 'Workflows', 'Durable', 'DurableTask')

# A URL to the license for this module.
LicenseUri = 'https://github.com/Azure/azure-functions-durable-powershell/blob/main/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/Azure/azure-functions-durable-powershell'

# ReleaseNotes of this module
# ReleaseNotes = '' #TODO: add release notes.

# Prerelease string of this module
#Prerelease = 'alpha'

} # End of PSData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = '' # TODO: explore
}
Loading

0 comments on commit 64502a6

Please sign in to comment.