Skip to content

Fix cross-platform deploy issues in Azure Copilot MicroHack#333

Merged
qxsch merged 3 commits intomicrosoft:mainfrom
nekdima:fix/azure-copilot-cross-platform-deploy
Apr 7, 2026
Merged

Fix cross-platform deploy issues in Azure Copilot MicroHack#333
qxsch merged 3 commits intomicrosoft:mainfrom
nekdima:fix/azure-copilot-cross-platform-deploy

Conversation

@nekdima
Copy link
Copy Markdown
Contributor

@nekdima nekdima commented Mar 27, 2026

Problem

Tested the Azure Copilot MicroHack deployment end-to-end on macOS (pwsh + az CLI) against a live Azure subscription. Found and fixed cross-platform deployment issues plus several robustness and documentation improvements.

Changelog

Deploy-Lab.ps1

Fix Description
Cross-platform temp path Replace $env:TEMP (Windows-only) with [System.IO.Path]::GetTempPath()
Zip deploy timeout Add --timeout 600 to az webapp deploy — Kudu/Oryx build on B1 exceeds default timeout
Replace Az module RBAC with az CLI Get-AzRoleAssignment/New-AzRoleAssignment requires Az module not available on macOS/Linux. Replaced with az role assignment list/create
Add shebang #!/usr/bin/env pwsh for direct execution on Linux/macOS
Fix Invoke-Az helper $args@args (proper splatting) + Write-Error; exitthrow (consistent error handling)
Fix ssh-keygen error handling Same Write-Error; exitthrow pattern for consistency

Test-CopilotWorkshop.ps1

Fix Description
Auto-install App Insights extension az extension add --name application-insights --yes prevents interactive hang
Add az login pre-flight check Check $LASTEXITCODE after az account show before proceeding
Strip UTF-8 BOM BOM before shebang prevents direct execution on Linux/macOS

Scripts (Send-CopilotTraffic.ps1, Remove-CopilotWorkshop.ps1)

Fix Description
Strip UTF-8 BOM Same BOM issue as Test script — kernel reads 0xEF instead of #!

app/app.py

Fix Description
Guard configure_azure_monitor() Crashes with ValueError if APPLICATIONINSIGHTS_CONNECTION_STRING not set. Now conditionally called only when env var is present

app/requirements.txt

Fix Description
Pin upper-bound versions flask>=3.0flask>=3.0,<4.0 etc. to prevent future breaking changes
Fix gunicorn pin <23.0<26.0 — current stable is 25.3.0; old pin excluded 2+ years of releases
Strip UTF-8 BOM BOM caused pip parse issues on some platforms

Documentation

Fix File
Add PowerShell 7+ as prerequisite Readme.md
Fix LinkedIn URL Readme.md — Contributors section
Add AKS clarification note challenge-06.md + solution-06.md — Task 3 references AKS cluster not deployed by lab
Add nav link to finish page challenge-07.md
Fix emoji shortcode finish.md:partying_face: → 🥳

- 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>
@nekdima
Copy link
Copy Markdown
Contributor Author

nekdima commented Mar 27, 2026

@qxsch can you please review and approve?

nekdima and others added 2 commits April 7, 2026 13:26
Additional improvements to the Azure Copilot MicroHack discovered via
dual advanced AI agent review (GPT-5.4-pro breadth + o3-pro robustness):

Deploy-Lab.ps1:
- Add missing shebang (#!/usr/bin/env pwsh) for consistency
- Fix Invoke-Az: use @Args splatting and throw instead of exit
- Replace Az PowerShell RBAC (Get/New-AzRoleAssignment) with az CLI
  commands for cross-platform compatibility

Test-CopilotWorkshop.ps1:
- Add pre-flight az login check before ConvertFrom-Json

app.py:
- Guard configure_azure_monitor() against missing connection string

requirements.txt:
- Pin upper-bound version constraints to prevent breaking changes

Readme.md:
- Add PowerShell 7+ (pwsh) as prerequisite
- Fix LinkedIn URL in Contributors section

challenges/challenge-06.md & walkthrough/solution-06.md:
- Add note that AKS cluster is not deployed; Task 3 is exploratory

challenges/challenge-07.md:
- Add navigation link to finish.md

challenges/finish.md:
- Replace GitHub emoji shortcode with Unicode emoji

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nt error handling

- Remove UTF-8 BOM (ef bb bf) from Test-CopilotWorkshop.ps1,
  Send-CopilotTraffic.ps1, Remove-CopilotWorkshop.ps1, and
  requirements.txt — BOM before shebang prevents direct execution
  on Linux/macOS (kernel reads 0xEF not 0x23)
- Widen gunicorn pin from <23.0 to <26.0 to include current stable
- Replace Write-Error+exit with throw in ssh-keygen check
  (consistent with Invoke-Az fix from prior commit)

Found via iterative GPT-5.4-pro red-team/counter-argue/verdict review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@qxsch qxsch self-requested a review April 7, 2026 13:36
@qxsch qxsch merged commit 88e45b6 into microsoft:main Apr 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants