From f9dec510408c7a8bc27dc63f316f86fbe78b699c Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 18 Oct 2023 20:59:26 -0700 Subject: [PATCH] Increased chunk size warning and got Function deployment working --- deployV2/deploy.ps1 | 53 +++++++++++++++++++++++++------------- deployV2/functionApp.bicep | 8 +++--- engine/host.json | 2 +- ui/vite.config.js | 3 +++ 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/deployV2/deploy.ps1 b/deployV2/deploy.ps1 index fb1f172..3c567bc 100644 --- a/deployV2/deploy.ps1 +++ b/deployV2/deploy.ps1 @@ -313,6 +313,7 @@ process { # Set preference variables $ErrorActionPreference = "Stop" $DebugPreference = 'SilentlyContinue' + $ProgressPreference = 'SilentlyContinue' # Hide Azure PowerShell SDK Warnings $Env:SuppressAzurePowerShellBreakingChangeWarnings = $true @@ -1008,42 +1009,58 @@ process { WRITE-HOST "INFO: Running NPM Build..." -ForegroundColor Green Write-Verbose -Message "INFO: Running NPM Build..." + Push-Location -Path '..\ui' + $npmBuildErr = $( - npm run build + $npmBuild = npm run build ) 2>&1 - WRITE-HOST "INFO: Creating ZIP Deploy archive..." -ForegroundColor Green - Write-Verbose -Message "INFO: Creating ZIP Deploy archive..." + Pop-Location if(-not $npmBuildErr) { + WRITE-HOST "INFO: Creating ZIP Deploy archive..." -ForegroundColor Green + Write-Verbose -Message "INFO: Creating ZIP Deploy archive..." + Compress-Archive -Path ..\engine\app -DestinationPath TEMP:\ipam.zip -Force Compress-Archive -Path ..\engine\requirements.txt -DestinationPath TEMP:\ipam.zip -Update Compress-Archive -Path ..\engine\scripts\* -DestinationPath TEMP:\ipam.zip -Update Compress-Archive -Path ..\engine\ipam-func -DestinationPath TEMP:\ipam.zip -Update Compress-Archive -Path ..\engine\ipam-sentinel -DestinationPath TEMP:\ipam.zip -Update + Compress-Archive -Path ..\engine\host.json -DestinationPath TEMP:\ipam.zip -Update Compress-Archive -Path ..\ui\dist -DestinationPath TEMP:\ipam.zip -Update + } else { + Write-Host "ERROR: Cannot create ZIP Deploy archive!" -ForegroundColor red + throw $npmBuildErr } - - $zipPath = Join-Path $(Get-PSDrive -Name Temp).Root -ChildPath "ipam.zip" - - WRITE-HOST "INFO: Uploading ZIP Deploy archive..." -ForegroundColor Green - Write-Verbose -Message "INFO: Uploading ZIP Deploy archive..." - - Publish-AzWebApp -ResourceGroupName $deployment.Outputs["resourceGroupName"].Value -Name $deployment.Outputs["appServiceName"].Value -ArchivePath $zipPath -Restart -Force | Out-Null } else { WRITE-HOST "INFO: Fetching ZIP Deploy archive..." -ForegroundColor Green Write-Verbose -Message "INFO: Fetching ZIP Deploy archive..." - $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest $IPAM_APP_ZIP -OutFile TEMP:\ipam.zip - - $zipPath = Join-Path $(Get-PSDrive -Name Temp).Root -ChildPath "ipam.zip" - - WRITE-HOST "INFO: Uploading ZIP Deploy archive..." -ForegroundColor Green - Write-Verbose -Message "INFO: Uploading ZIP Deploy archive..." - - Publish-AzWebApp -ResourceGroupName $deployment.Outputs["resourceGroupName"].Value -Name $deployment.Outputs["appServiceName"].Value -ArchivePath $zipPath -Restart -Force | Out-Null } + + WRITE-HOST "INFO: Uploading ZIP Deploy archive..." -ForegroundColor Green + Write-Verbose -Message "INFO: Uploading ZIP Deploy archive..." + + $zipPath = Join-Path $(Get-PSDrive -Name Temp).Root -ChildPath "ipam.zip" + + $publishRetries = 5 + $publishSuccess = $False + + do { + try { + Publish-AzWebApp -ResourceGroupName $deployment.Outputs["resourceGroupName"].Value -Name $deployment.Outputs["appServiceName"].Value -ArchivePath $zipPath -Restart -Force | Out-Null + $publishSuccess = $True + } catch { + if($publishRetries -gt 0) { + Write-Host "WARNING: Problem while uploading ZIP Deploy archive! Retrying..." -ForegroundColor DarkYellow + $publishRetries-- + } else { + Write-Host "ERROR: Unable to upload ZIP Deploy archive!" -ForegroundColor Red + throw $_ + } + } + } while ($publishSuccess -eq $False -and $publishRetries -gt 0) } if ($PSCmdlet.ParameterSetName -in ('AppContainer', 'FunctionContainer') -and $PrivateAcr) { diff --git a/deployV2/functionApp.bicep b/deployV2/functionApp.bicep index 8c63b45..d178ef3 100644 --- a/deployV2/functionApp.bicep +++ b/deployV2/functionApp.bicep @@ -134,10 +134,6 @@ resource functionApp 'Microsoft.Web/sites@2021-03-01' = { name: 'WEBSITE_CONTENTSHARE' value: toLower(functionAppName) } - { - name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' - value: 'false' - } { name: 'FUNCTIONS_EXTENSION_VERSION' value: '~4' @@ -159,6 +155,10 @@ resource functionApp 'Microsoft.Web/sites@2021-03-01' = { value: privateAcr ? 'https://${privateAcrUri}' : 'https://index.docker.io/v1' } ] : [ + { + name: 'FUNCTIONS_WORKER_RUNTIME' + value: 'python' + } { name: 'SCM_DO_BUILD_DURING_DEPLOYMENT' value: 'true' diff --git a/engine/host.json b/engine/host.json index f292709..6d10d82 100644 --- a/engine/host.json +++ b/engine/host.json @@ -15,6 +15,6 @@ }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", - "version": "[2.*, 3.0.0)" + "version": "[4.*, 5.0.0)" } } diff --git a/ui/vite.config.js b/ui/vite.config.js index 084b7e8..17046bd 100644 --- a/ui/vite.config.js +++ b/ui/vite.config.js @@ -45,6 +45,9 @@ export default () => { define: { IPAM_VERSION: JSON.stringify(process.env.npm_package_version), }, + build: { + chunkSizeWarningLimit: 5120 + }, logLevel: 'warn' }) }