{"id":26156780,"url":"https://github.com/jmservera/private-webapp","last_synced_at":"2026-01-28T04:07:01.327Z","repository":{"id":279665971,"uuid":"939551389","full_name":"jmservera/private-webapp","owner":"jmservera","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-02T23:02:08.000Z","size":110,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T08:18:24.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Bicep","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmservera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-26T18:11:04.000Z","updated_at":"2025-03-23T10:09:02.000Z","dependencies_parsed_at":"2025-03-13T22:23:28.336Z","dependency_job_id":"d4dd400f-0462-444f-96ac-d18742a0c0b8","html_url":"https://github.com/jmservera/private-webapp","commit_stats":null,"previous_names":["jmservera/private-webapp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jmservera/private-webapp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmservera%2Fprivate-webapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmservera%2Fprivate-webapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmservera%2Fprivate-webapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmservera%2Fprivate-webapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmservera","download_url":"https://codeload.github.com/jmservera/private-webapp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmservera%2Fprivate-webapp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28838009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T09:32:37.740Z","updated_at":"2026-01-28T04:07:01.321Z","avatar_url":"https://github.com/jmservera.png","language":"Bicep","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebApp with Private Backend and Database\n\nThis repository demonstrates deploying a secure web application architecture on Azure, featuring a publicly accessible frontend, a private backend, and a private SQL database. It leverages Azure private endpoints, VNet integration, managed identities, and GitHub Actions for CI/CD automation.\n\n## Architecture Overview\n\nThe solution deploys the following Azure resources:\n\n- **Virtual Network (VNet)** with four subnets:\n  - **App subnet**: Hosts frontend and backend web apps with VNet integration.\n  - **Private subnet**: Dedicated to private endpoints for secure internal communication.\n  - **VM subnet**: Hosts the GitHub Actions self-hosted runner VM.\n  - **CI subnet**: Used by deployment scripts running in Azure Container Instances.\n- **Frontend Web App**: Publicly accessible, communicates securely with the backend via private endpoints.\n- **Backend Web App**: Private access only, uses a user-assigned managed identity for secure database access.\n- **Azure SQL Database**: Private access via private endpoint, initialized with custom scripts.\n- **Azure Container Registry (ACR)**: Stores Docker images for frontend and backend applications.\n- **GitHub Runner VM**: Self-hosted runner for secure CI/CD within the private network.\n- **Application Insights**: Integrated telemetry and monitoring for frontend and backend applications.\n\n### Network Architecture\n\nThe solution uses a single VNet with clearly defined subnets and private endpoints to secure internal communication:\n\n- **Frontend Web App**: Publicly accessible, connects securely to the backend via private endpoints.\n- **Backend Web App**: Not publicly accessible, communicates securely with the SQL database via private endpoints.\n- **GitHub Runner VM**: Deployed within the same VNet, enabling secure CI/CD operations and access to private resources.\n\n## Prerequisites\n\nBefore deploying, ensure you have:\n\n1. Azure CLI installed and authenticated.\n1. [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/) extension installed.\n2. GitHub repository for your application code.\n3. GitHub Personal Access Token (PAT) with appropriate permissions:\n    * Actions Access: Read-only\n    * Administration Access: Read and write\n    * Metadata Access: Read-only\n    * Secrets Access: Read and write\n    * Variables Access: Read and write\n\n\n\n## Deployment\n\nUse the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/) to deploy the solution:\n\n```bash\naz login\nazd up\n```\n\nYou'll be prompted for:\n\n- Environment name (prefix for resources)\n- Azure region for deployment\n- SQL administrator username and password\n- GitHub repository owner and name\n- GitHub PAT for GitHub Actions\n\n\n## GitHub Actions Runner Setup\n\nThe GitHub Actions runner is automatically configured during deployment via a custom VM extension script ([`scripts/install-packages.sh`](scripts/install-packages.sh)). This script:\n\n- Installs required packages (Docker, Azure CLI, GitHub CLI).\n- Registers the VM as a self-hosted runner in your GitHub repository.\n- Configures multiple runner instances for parallel CI/CD jobs.\n\nTo verify or manage runners:\n\n1. Navigate to your GitHub repository.\n2. Go to **Settings** \u003e **Actions** \u003e **Runners**.\n3. Confirm the self-hosted runners are online and correctly configured.\n\n## Database Initialization\n\nThe SQL database is initialized automatically during deployment using a custom Azure deployment script ([`scripts/create-sql-user.sh`](scripts/create-sql-user.sh)). This script:\n\n- Creates a database user linked to the backend's managed identity.\n- Assigns appropriate database roles (`db_datareader`, `db_datawriter`, `db_ddladmin`).\n- Creates the required tables (`Value_Store`) if they don't exist.\n\nEnsure the deployment script is correctly referenced in your Bicep files ([`infra/modules/sqlDatabase.bicep`](infra/modules/sqlDatabase.bicep)).\n\n## Telemetry and Monitoring\n\nBoth frontend and backend applications integrate with Azure Application Insights for comprehensive telemetry:\n\n- **Backend** ([`src/backend/app.py`](src/backend/app.py)):\n  - Uses OpenTelemetry instrumentation for Flask and database interactions.\n  - Sends logs, metrics, and traces to Application Insights.\n\n- **Frontend** ([`src/frontend/app.py`](src/frontend/app.py)):\n  - Uses OpenTelemetry instrumentation for Flask.\n  - Captures user interactions, HTTP requests, and errors.\n\nTelemetry is configured via the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable, automatically set during deployment.\n\n## Security Features\n\n- **HTTPS and TLS 1.2** enforced on all web apps.\n- **Private endpoints** for secure internal communication between frontend, backend, and database.\n- **Firewall rules** restrict external access to sensitive resources.\n- **Managed identities** used for secure, passwordless authentication.\n- **VNet integration** ensures secure network isolation and communication.\n\n## Scripts Overview\n\nThe repository includes several scripts to automate setup and management tasks:\n\n- [`scripts/install-packages.sh`](scripts/install-packages.sh): Installs dependencies and configures GitHub Actions runners on the VM. By default, it creates two runner instances for parallel CI/CD jobs.\n- [`scripts/create-sql-user.sh`](scripts/create-sql-user.sh): Initializes the SQL database and configures the managed identity access. Uses a trick to avoid needing a highly privileged user for adding the managed identity to the database.\n- [`scripts/set-github-vars.sh`](scripts/set-github-vars.sh): Sets GitHub repository variables required for CI/CD workflows after running `azd up`. Then it launches the CI/CD pipeline.\n- [`scripts/create-sql-user.sh`](scripts/create-sql-user.sh): Initializes the SQL database and configures the managed identity access. Uses a trick to avoid needing a highly privileged user for adding the managed identity to the database.\n\nThese scripts are automatically executed during deployment and VM provisioning.\n\n## Next Steps\n\n- Customize the frontend and backend applications as needed.\n- Regularly review and update dependencies using Dependabot ([`.github/dependabot.yml`](.github/dependabot.yml)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmservera%2Fprivate-webapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmservera%2Fprivate-webapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmservera%2Fprivate-webapp/lists"}