feat: harden local-dev and Azure deploy automation scripts with prereq, role and retry safeguards#1009
feat: harden local-dev and Azure deploy automation scripts with prereq, role and retry safeguards#1009Rafi-Microsoft wants to merge 21 commits into
Conversation
- setup_local_dev.sh/.ps1: Automates full local development setup - Prerequisite checks with detailed install guidance - Azure config fetch from Resource Group (container app or individual resources) - RBAC role assignment with pre-check (Cosmos DB, AI Foundry, Search, Storage) - Virtual environment setup for backend, MCP server, and frontend - VS Code settings and launch.json generation - Auto-fix for .venv lock issues (VS Code Python extension) - deploy_to_azure.sh/.ps1: Deploys local code changes to Azure - Builds Docker images for selected services (backend, mcp, frontend) - Pushes to ACR with unique timestamp+git-sha tags - Updates Container Apps and App Service with new images - ACR discovery, creation, and AcrPull role assignment - Dry-run mode, build-only/deploy-only modes - Rollback commands printed after deployment - .gitignore: Added local dev artifacts (.macae_*.pid, start_all_services.sh) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…signment, and change detection
…Linux/macOS and Windows
Remove local dev setup artifacts from .gitignore
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix Write-LogWarn crash from extra -ForegroundColor parameter (deploy_to_azure.ps1) - Fix misleading git diff warning message in both deploy scripts - Change -r to -g short flag for --resource-group to match docs (setup_local_dev.sh) - Gate RBAC assignment behind --assign-rbac / -AssignRbac flag (both setup scripts) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
RBAC roles are essential for local dev and should always be assigned. The script already skips roles that are already assigned, so running unconditionally is safe and simplifies the user experience. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Moved all 4 scripts to scripts/ directory and updated all references in docs/AutomatedLocalSetup.md and docs/DeployLocalChanges.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Scripts now compute REPO_ROOT as two levels up from their location in infra/scripts/, so all src/ and .azure/ paths resolve correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nce in setup scripts
…b.com/microsoft/Multi-Agent-Custom-Automation-Engine-Solution-Accelerator into feature/local_automation_enhancements
This reverts commit 12c3c8f.
This reverts commit 0b561fa.
There was a problem hiding this comment.
Pull request overview
Adds cross-platform (Bash + PowerShell) automation for local development setup and for deploying local code changes to an existing Azure deployment, with prerequisite checks, Azure role/permission validation, retry/fallback behaviors, and improved run summaries. This fits into the repo’s infra/scripts/ tooling and complements the existing manual setup/deployment docs by providing repeatable, guided workflows.
Changes:
- Add
setup_local_devscripts to generate backend.env, assign required roles, install deps (uv/pip/npm), and optionally scaffold VS Code config. - Add
deploy_to_azurescripts to build/push images to ACR, configure registry settings, update Container Apps/App Service, and print rollback commands. - Add documentation pages describing usage, flags, and expected flow for both workflows.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| infra/scripts/setup_local_dev.sh | New Bash local-dev setup automation (prereqs, auth, config, RBAC, installs, VS Code scaffolding). |
| infra/scripts/setup_local_dev.ps1 | New PowerShell local-dev setup automation mirroring Bash behavior. |
| infra/scripts/deploy_to_azure.sh | New Bash deploy-to-Azure automation with retries, ACR resolution, per-service build results, rollback output. |
| infra/scripts/deploy_to_azure.ps1 | New PowerShell deploy-to-Azure automation mirroring Bash behavior. |
| docs/AutomatedLocalSetup.md | Documentation for running the local-dev setup scripts. |
| docs/DeployLocalChanges.md | Documentation for running the deploy-to-Azure scripts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolves 12 inline comments from Copilot reviewer on PR #1009: setup_local_dev.sh: * Add Bash 4+ requirement check at top (macOS ships 3.2 — `declare -A` is not available there). Fail with actionable Homebrew install hint. * Remove silent fallback to Python <3.12 in interpreter detection; rely on check_prerequisites to fail loudly when 3.12+ is missing. * Make generated .vscode/settings.json `python.defaultInterpreterPath` OS-aware (bin/python on Linux/macOS, Scripts/python.exe on Windows). setup_local_dev.ps1: * Add `#Requires -Version 7.0` plus runtime guard — `??` and `Out-File -Encoding utf8NoBOM` aren't supported on Windows PowerShell 5.1. * Remember the detected Python invocation (e.g., `py -3.12`) and reuse it when creating the frontend venv, instead of unconditionally calling `python -m venv` (which fails when `python` isn't on PATH). deploy_to_azure.sh: * Fix az_retry comment to say "up to 4 attempts" to match the loop bound. * Correct step header in update_azure_resources from "Step 7" to "Step 8" so log output matches docs/section structure. * Add `_has_az_executable` helper using `type -P az` so the prereq check isn't satisfied by the `az()` wrapper function defined earlier in the script when the real Azure CLI isn't installed. deploy_to_azure.ps1: * In Configure-AcrOnResources, capture exit code of BOTH frontend `az webapp config` calls. Previously only the second was checked, so a failure to set DOCKER_REGISTRY_SERVER_URL could be silently masked by a successful acrUseManagedIdentityCreds update. docs: * DeployLocalChanges.md — add Step 1b (Azure roles & permissions check) to the "What It Does (in order)" list. * AutomatedLocalSetup.md — add Step 2b (Azure roles & permissions check) to the "What It Does (in order)" list. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addressed Copilot review feedback in commit d565c8aThanks @copilot for the review — all 12 inline comments have been addressed:
Validation: all 4 scripts pass syntax checks ( |
Purpose
Harden the local-dev and deploy-to-Azure automation scripts (PowerShell + Bash) with prerequisite checks, role-permission validation, retry/fallback logic, and a per-service build results summary. Also adds the supporting documentation.
Scope of this PR
infra/scripts/deploy_to_azure.ps1/.sh— production deploy automationinfra/scripts/setup_local_dev.ps1/.sh— one-shot local-dev environment setupdocs/AutomatedLocalSetup.md,docs/DeployLocalChanges.md— usage guidesKey changes
Azure AI User,Azure AI Developer) that may not exist in older subscriptions or sovereign clouds.2(vs. hard-fail1) when role assignments fail but the rest of setup succeeded, so CI can distinguish.uv sync→ retried once with--refreshon failure.npm install→ retried once with--legacy-peer-depson failure.Revert "removed mount from dockerfiles",Revert "docker image time optimization v1") — dockerfile changes deferred to a separate PR; backed up locally via git tagsdockerfile-backup/*.Does this introduce a breaking change?
How to Test
git clone https://github.com/microsoft/Multi-Agent-Custom-Automation-Engine-Solution-Accelerator.git cd Multi-Agent-Custom-Automation-Engine-Solution-Accelerator git checkout feature/local_automation_enhancementsDeploy script (dry-run, safe — no Azure changes):
Setup local dev:
Validation performed
bash -non.shfiles, PowerShellPSParser::Tokenizeon.ps1files — all pass.0; new step1b / 2b: Checking Azure Roles & Permissionsrendered correctly; build-results table rendered in deploy summary.What to Check
Report-FailedRoleAssignments/report_failed_role_assignmentsonly fires when at least one role assignment actually failed; exit code is2in that case,0otherwise.uv syncandnpm installretries surface the retry attempt in output before failing hard.[OK] / [FAIL] / dry-runper service).pm install,pm run build, stray pwsh path) is pre-existing PowerShell display behavior, not introduced here.Other Information
az role assignment list --include-inherited --include-groupsand are intentionally non-fatal (group/conditional grants can't always be enumerated).Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com