From dc601ec50ea82b33e38aa90f695b3b0a97d490f8 Mon Sep 17 00:00:00 2001 From: Dmitriy Nekrasov Date: Fri, 27 Mar 2026 15:01:45 +0100 Subject: [PATCH] Fix cross-platform deploy issues in Azure Copilot MicroHack - Replace $env:TEMP with [System.IO.Path]::GetTempPath() in Deploy-Lab.ps1 ($env:TEMP is null on macOS/Linux, causing script to crash) - Add --timeout 600 to az webapp deploy to prevent 504 Gateway Timeout during Oryx Python build on B1 App Service plan - Auto-install application-insights CLI extension in Test-CopilotWorkshop.ps1 to prevent interactive prompt that hangs the test suite Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../12_Azure_Copilot/lab/Deploy-Lab.ps1 | 6 +++--- .../12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1 | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/03-Azure/01-03-Infrastructure/12_Azure_Copilot/lab/Deploy-Lab.ps1 b/03-Azure/01-03-Infrastructure/12_Azure_Copilot/lab/Deploy-Lab.ps1 index a5d8c81b..f7d81952 100644 --- a/03-Azure/01-03-Infrastructure/12_Azure_Copilot/lab/Deploy-Lab.ps1 +++ b/03-Azure/01-03-Infrastructure/12_Azure_Copilot/lab/Deploy-Lab.ps1 @@ -96,7 +96,7 @@ $sshPublicKey = (Get-Content $sshPubKeyPath -Raw).Trim() Write-Host "`n[1/3] Deploying infrastructure (Bicep)..." -ForegroundColor Yellow $mainBicep = Join-Path $scriptPath "..\iac\main.bicep" $timestamp = Get-Date -Format "yyyyMMddHHmmss" -$paramsFile = Join-Path $env:TEMP "copilot-workshop-params-$timestamp.json" +$paramsFile = Join-Path ([System.IO.Path]::GetTempPath()) "copilot-workshop-params-$timestamp.json" @{ '`$schema' = 'https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#' @@ -127,10 +127,10 @@ Write-Host " ✓ Infrastructure deployed" -ForegroundColor Green Write-Host "`n[2/3] Deploying buggy Flask app (Ch02)..." -ForegroundColor Yellow $webAppName = "app-copilot-buggy-$suffix" $appDir = Join-Path $scriptPath "..\app" -$zipPath = Join-Path $env:TEMP "$webAppName.zip" +$zipPath = Join-Path ([System.IO.Path]::GetTempPath()) "$webAppName.zip" if (Test-Path $zipPath) { Remove-Item $zipPath -Force } Compress-Archive -Path (Join-Path $appDir "*") -DestinationPath $zipPath -Force -Invoke-Az webapp deploy --resource-group "rg-copilot-$suffix-ch02" --name $webAppName --src-path $zipPath --type zip --track-status false -o none +Invoke-Az webapp deploy --resource-group "rg-copilot-$suffix-ch02" --name $webAppName --src-path $zipPath --type zip --track-status false --timeout 600 -o none Remove-Item $zipPath -Force Write-Host " ✓ Flask app deployed to $webAppName" -ForegroundColor Green diff --git a/03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1 b/03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1 index 2fbebda3..131bc4a1 100644 --- a/03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1 +++ b/03-Azure/01-03-Infrastructure/12_Azure_Copilot/scripts/Test-CopilotWorkshop.ps1 @@ -18,6 +18,9 @@ param( $ErrorActionPreference = "Continue" Set-StrictMode -Version Latest +# Ensure required CLI extensions are installed (application-insights is needed for Ch02 tests) +az extension add --name application-insights --yes 2>$null + $passed = 0 $failed = 0 $warnings = 0