File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Modules/CIPPCore/Public/GraphHelper Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,19 @@ function Update-CIPPAzFunctionAppSetting {
6262 $currentProps [$prop.Name ] = [string ]$prop.Value
6363 }
6464 }
65+ } else {
66+ # Could not retrieve current settings - backfill from EnvVarBackup to avoid overwriting required properties with empty values
67+ Write-Warning " Could not retrieve current Function App settings for $Name - attempting to backfill from environment variable backup."
68+ $EnvBackupTable = Get-CIPPTable - tablename ' EnvVarBackups'
69+ $BackupEntity = Get-CIPPAzDataTableEntity @EnvBackupTable - Filter " PartitionKey eq 'EnvVarBackup' and RowKey eq '$Name '"
70+ if ($BackupEntity -and $BackupEntity.Values ) {
71+ ($BackupEntity.Values | ConvertFrom-Json ).PSObject.Properties | ForEach-Object {
72+ if ($_.Value ) { $currentProps [$_.Name ] = [string ]$_.Value }
73+ }
74+ Write-Information " Backfilled $ ( $currentProps.Count ) properties from environment variable backup for $Name "
75+ } else {
76+ throw " Failed to retrieve current settings for Function App $Name and no backup found - aborting update to avoid potential misconfiguration."
77+ }
6578 }
6679
6780 # Merge requested settings
You can’t perform that action at this time.
0 commit comments