Skip to content

Commit e203c2e

Browse files
Merge pull request KelvinTegelaar#1631 from Zacgoose/docker_lb_updates
Add NonLocalHostAzurite support and update PowerShell version
2 parents 53f8b8f + 3b9d84a commit e203c2e

File tree

15 files changed

+29
-26
lines changed

15 files changed

+29
-26
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FUNCTIONS_WORKER_RUNTIME='powershell'
2+
FUNCTIONS_WORKER_RUNTIME_VERSION='7.4'
3+
AzureWebJobsStorage='DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNoBnZf6KgBVU4=;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;'
4+
DEV_SKIP_BPA_TIMER='true'
5+
DEV_SKIP_DOMAIN_TIMER='true'
6+
FUNCTIONS_EXTENSION_VERSION='4'
7+
NonLocalHostAzurite='true'

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To enable ssh & remote debugging on app service change the base image to the one below
22
# FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2-appservice
3-
FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2
3+
FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.4
44
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
55
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
66

7-
COPY . /home/site/wwwroot
7+
COPY . /home/site/wwwroot

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-GetCippAlerts.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function Invoke-GetCippAlerts {
6060
type = 'error'
6161
})
6262
}
63-
if ((!$env:WEBSITE_RUN_FROM_PACKAGE -or [string]::IsNullOrEmpty($env:WEBSITE_RUN_FROM_PACKAGE)) -and $env:AzureWebJobsStorage -ne 'UseDevelopmentStorage=true') {
63+
if ((!$env:WEBSITE_RUN_FROM_PACKAGE -or [string]::IsNullOrEmpty($env:WEBSITE_RUN_FROM_PACKAGE)) -and $env:AzureWebJobsStorage -ne 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -ne 'true') {
6464
$Alerts.Add(
6565
@{
6666
title = 'Function App in Write Mode'

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecCombinedSetup.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Invoke-ExecCombinedSetup {
1414
$Results = [System.Collections.ArrayList]::new()
1515
try {
1616
# Set up Azure context if needed for Key Vault access
17-
if ($env:AzureWebJobsStorage -ne 'UseDevelopmentStorage=true' -and $env:MSI_SECRET) {
17+
if ($env:AzureWebJobsStorage -ne 'UseDevelopmentStorage=true' -and $env:MSI_SECRET -or $env:NonLocalHostAzurite -ne 'true') {
1818
Disable-AzContextAutosave -Scope Process | Out-Null
1919
$null = Connect-AzAccount -Identity
2020
$SubscriptionId = $env:WEBSITE_OWNER_NAME -split '\+' | Select-Object -First 1
@@ -67,7 +67,7 @@ function Invoke-ExecCombinedSetup {
6767
if ($Request.Body.selectedOption -eq 'Manual') {
6868
$KV = $env:WEBSITE_DEPLOYMENT_ID
6969

70-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
70+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
7171
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
7272
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
7373
if (!$Secret) {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecCreateSAMApp.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Invoke-ExecCreateSAMApp {
7272
}
7373
$AppPassword = (Invoke-RestMethod "https://graph.microsoft.com/v1.0/applications/$($AppId.id)/addPassword" -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body '{"passwordCredential":{"displayName":"CIPPInstall"}}' -ContentType 'application/json').secretText
7474

75-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
75+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
7676
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
7777
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
7878
if (!$Secret) { $Secret = New-Object -TypeName PSObject }

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecSAMSetup.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Invoke-ExecSAMSetup {
2828
$Headers = $Request.Headers
2929
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
3030

31-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
31+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
3232
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
3333
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
3434
if (!$Secret) {
@@ -63,7 +63,7 @@ function Invoke-ExecSAMSetup {
6363
if ($Request.Query.count -lt 1 ) { $Results = 'No authentication code found. Please go back to the wizard.' }
6464

6565
if ($Request.Body.setkeys) {
66-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
66+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
6767
if ($Request.Body.TenantId) { $Secret.TenantId = $Request.Body.tenantid }
6868
if ($Request.Body.RefreshToken) { $Secret.RefreshToken = $Request.Body.RefreshToken }
6969
if ($Request.Body.applicationid) { $Secret.ApplicationId = $Request.Body.ApplicationId }
@@ -86,7 +86,7 @@ function Invoke-ExecSAMSetup {
8686
$AppID = $Rows.appid
8787
if (!$AppID -or $AppID -eq 'NotStarted') { $appid = $env:ApplicationID }
8888
$URL = ($Request.headers.'x-ms-original-url').split('?') | Select-Object -First 1
89-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
89+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
9090
$clientsecret = $Secret.ApplicationSecret
9191
} else {
9292
$clientsecret = Get-AzKeyVaultSecret -VaultName $kv -Name 'ApplicationSecret' -AsPlainText
@@ -95,7 +95,7 @@ function Invoke-ExecSAMSetup {
9595
Write-Information "client_id=$appid&scope=https://graph.microsoft.com/.default+offline_access+openid+profile&code=$($Request.Query.code)&grant_type=authorization_code&redirect_uri=$($url)&client_secret=$clientsecret" #-Uri "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token"
9696
$RefreshToken = Invoke-RestMethod -Method POST -Body "client_id=$appid&scope=https://graph.microsoft.com/.default+offline_access+openid+profile&code=$($Request.Query.code)&grant_type=authorization_code&redirect_uri=$($url)&client_secret=$clientsecret" -Uri "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token" -ContentType 'application/x-www-form-urlencoded'
9797

98-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
98+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
9999
$Secret.RefreshToken = $RefreshToken.refresh_token
100100
Add-CIPPAzDataTableEntity @DevSecretsTable -Entity $Secret -Force
101101
} else {
@@ -192,7 +192,7 @@ function Invoke-ExecSAMSetup {
192192
} until ($attempt -gt 5)
193193
}
194194
$AppPassword = (Invoke-RestMethod "https://graph.microsoft.com/v1.0/applications/$($AppId.id)/addPassword" -Headers @{ authorization = "Bearer $($Token.access_token)" } -Method POST -Body '{"passwordCredential":{"displayName":"CIPPInstall"}}' -ContentType 'application/json').secretText
195-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
195+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
196196
$Secret.TenantId = $TenantId
197197
$Secret.ApplicationId = $AppId.appId
198198
$Secret.ApplicationSecret = $AppPassword

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecTokenExchange.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Function Invoke-ExecTokenExchange {
3434
# Make sure we get the latest authentication
3535
$auth = Get-CIPPAuthentication
3636

37-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
37+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
3838
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
3939
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
4040
$ClientSecret = $Secret.applicationsecret

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecUpdateRefreshToken.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function Invoke-ExecUpdateRefreshToken {
1717
# Handle refresh token update
1818
#make sure we get the latest authentication:
1919
$auth = Get-CIPPAuthentication
20-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
20+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
2121
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
2222
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
2323

Modules/CIPPCore/Public/Entrypoints/Invoke-ExecListAppId.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Function Invoke-ExecListAppId {
1515
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
1616
$ResponseURL = "$(($Request.headers.'x-ms-original-url').replace('/api/ExecListAppId','/api/ExecSAMSetup'))"
1717
#make sure we get the very latest version of the appid from kv:
18-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
18+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
1919
$DevSecretsTable = Get-CIPPTable -tablename 'DevSecrets'
2020
$Secret = Get-CIPPAzDataTableEntity @DevSecretsTable -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
2121
$env:ApplicationID = $Secret.ApplicationID

Modules/CIPPCore/Public/Entrypoints/Timer Functions/Start-UpdateTokensTimer.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Start-UpdateTokensTimer {
1313
$currentUTCtime = (Get-Date).ToUniversalTime()
1414
try {
1515
$Refreshtoken = (Get-GraphToken -ReturnRefresh $true).Refresh_token
16-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
16+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
1717
$Table = Get-CIPPTable -tablename 'DevSecrets'
1818
$Secret = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
1919
if ($Secret) {
@@ -57,7 +57,7 @@ function Start-UpdateTokensTimer {
5757
}
5858

5959
if ($AppSecret) {
60-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
60+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
6161
$Table = Get-CIPPTable -tablename 'DevSecrets'
6262
$Secret = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
6363
$Secret.ApplicationSecret = $AppSecret.secretText
@@ -99,7 +99,7 @@ function Start-UpdateTokensTimer {
9999
try {
100100
Write-Information "Updating refresh token for tenant $($Tenant.displayName) - $($Tenant.customerId)"
101101
$Refreshtoken = (Get-GraphToken -ReturnRefresh $true -TenantId $Tenant.customerId).Refresh_token
102-
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true') {
102+
if ($env:AzureWebJobsStorage -eq 'UseDevelopmentStorage=true' -or $env:NonLocalHostAzurite -eq 'true') {
103103
$Table = Get-CIPPTable -tablename 'DevSecrets'
104104
$Secret = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'Secret' and RowKey eq 'Secret'"
105105
if ($Secret) {

0 commit comments

Comments
 (0)