fix: update the local development scripts, readme and custom deployment pre provision hook#813
fix: update the local development scripts, readme and custom deployment pre provision hook#813Ragini-Microsoft wants to merge 6 commits intodevfrom
Conversation
These files were not referenced anywhere in the codebase. Local development is handled by scripts/local_dev.ps1 and scripts/local_dev.sh. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors the local development experience by making the PowerShell and Bash dev scripts more “self-healing” (auto-setup / auto-env generation), improving service output handling, and updating the local dev documentation accordingly.
Changes:
- Update
local_dev.ps1/local_dev.shto auto-run setup steps when prerequisites are missing and improve process output labeling/handling. - Fix Bash
PYTHONPATHto point at the backend directory for correct module resolution. - Expand/refresh the local development setup guide and remove unused legacy start scripts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/local_dev.ps1 |
Adds auto-setup/env generation, safer directory handling, and job output labeling for backend/frontend. |
scripts/local_dev.sh |
Adds auto-setup/env generation, fixes PYTHONPATH, and improves help discoverability. |
docs/LocalDevelopmentSetup.md |
Major rewrite/expansion of local setup instructions and env var reference. |
src/start.sh |
Removed unused legacy startup script. |
src/start.cmd |
Removed unused legacy startup script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (-not (Test-Path ".env")) { | ||
| Write-Warning ".env file not found. Generating from Azure resources..." | ||
| Invoke-EnvGeneration |
There was a problem hiding this comment.
Start-All calls Invoke-EnvGeneration when .env is missing, but Invoke-EnvGeneration’s non-azd fallback only copies from .env.template (which doesn’t exist in this repo; there is .env.sample). If azd isn’t available, Start-All will proceed without a .env and then role assignment helpers will fail with less actionable errors. After Invoke-EnvGeneration, explicitly verify that .env exists (or copy from .env.sample) and stop with a clear next-step message if it still doesn’t.
| if (-not (Test-Path ".env")) { | |
| Write-Warning ".env file not found. Generating from Azure resources..." | |
| Invoke-EnvGeneration | |
| $envFile = Join-Path $ProjectRoot ".env" | |
| $envSampleFile = Join-Path $ProjectRoot ".env.sample" | |
| if (-not (Test-Path $envFile)) { | |
| Write-Warning ".env file not found. Generating from Azure resources..." | |
| Invoke-EnvGeneration | |
| if (-not (Test-Path $envFile) -and (Test-Path $envSampleFile)) { | |
| Write-Warning "Invoke-EnvGeneration did not create .env. Copying .env.sample to .env as a fallback..." | |
| Copy-Item $envSampleFile $envFile | |
| Write-Info "Created .env from .env.sample. Update the file with your local values if needed." | |
| } | |
| if (-not (Test-Path $envFile)) { | |
| throw "Failed to create .env. Run '.\scripts\local_dev.ps1 -Command env' to generate it from Azure resources, or create '.env' manually from '.env.sample' and rerun the script." | |
| } |
| # Auto-run env generation if .env is missing | ||
| if [ ! -f ".env" ]; then | ||
| print_warning ".env file not found. Generating from Azure resources..." | ||
| generate_env |
There was a problem hiding this comment.
start_all auto-runs generate_env when .env is missing, but generate_env’s non-azd fallback only copies from .env.template (this repo has .env.sample, not .env.template). If azd isn’t installed, start_all continues without a .env and later role assignment helpers will fail with less actionable errors. After generate_env, re-check that .env exists (or copy from .env.sample) and exit with a clear message if it still doesn’t.
| generate_env | |
| generate_env | |
| if [ ! -f ".env" ] && [ -f ".env.sample" ]; then | |
| print_warning "generate_env did not create .env. Falling back to .env.sample..." | |
| cp ".env.sample" ".env" | |
| fi | |
| if [ ! -f ".env" ]; then | |
| print_error "Unable to create .env. Please run './local_dev.sh env' or create '$PROJECT_ROOT/.env' manually (you can start from .env.sample if available)." | |
| exit 1 | |
| fi |
| sudo apt update && sudo apt install python3.11 python3.11-venv git curl nodejs npm -y | ||
|
|
There was a problem hiding this comment.
The Linux prerequisite command installs nodejs/npm from the default apt repositories, which often does not provide Node.js 18+ (the stated minimum). Update these instructions to install a Node 18+ source (e.g., NodeSource repo or nvm), or clarify the minimum supported distro versions where apt provides Node 18+.
| sudo apt update && sudo apt install python3.11 python3.11-venv git curl nodejs npm -y | |
| sudo apt update && sudo apt install python3.11 python3.11-venv git curl ca-certificates -y | |
| # Install Node.js 18.x from NodeSource | |
| curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - | |
| sudo apt install nodejs -y |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Purpose
This pull request introduces several improvements to local development scripts, deployment automation, and environment setup to streamline the developer experience and make deployment processes more robust. The changes focus on better handling of environment files, enhanced automation for prerequisites, improved deployment hooks, and cleanup of legacy scripts.
Key changes include:
Local Development Script Improvements
Updated both PowerShell (
scripts/local_dev.ps1) and Bash (scripts/local_dev.sh) scripts to prefer.env.sampleover.env.templatefor generating.envfiles, and improved logic for generating, refreshing, and falling back to.envif missing. The scripts now prompt users to refresh.envfrom Azure resources and automatically run setup steps if prerequisites (like virtual environments or dependencies) are missing. [1] [2] [3] [4] [5] [6]Enhanced backend and frontend start functions to use
Push-Location/Pop-Locationfor safer directory changes and to suppress benign shutdown errors, improving robustness and user experience. [1] [2] [3]Improved the "start all" workflow to display colored, prefixed output for backend and frontend logs, and to handle job failures more gracefully. [1] [2]
Added a
helpcommand to the Bash script for easier discovery of available commands. [1] [2]Deployment Automation Enhancements
azure_custom.yamlto better detect and handle first deployments, ACR (Azure Container Registry) image existence, and ACI (Azure Container Instance) redeployments. The hooks now clear container instance names and skip deployments as appropriate, and restart ACI to ensure new images are picked up. [1] [2] [3] [4]Environment and Documentation Updates
Added missing environment variable samples (
COSMOSDB_ACCOUNT_NAME,RESOURCE_GROUP_NAME) to.env.samplefor clarity and completeness. [1] [2]Updated documentation to clarify that deploying local changes is an advanced operation.
Cleanup
src/start.sh,src/start.cmd) in favor of the improved local development scripts. [1] [2]Minor Fixes
PYTHONPATHexport in the Bash script to use the backend directory instead of the source directory.Does this introduce a breaking change?
Golden Path Validation
Deployment Validation