Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

feat: migrate from SWA to ACA#36

Merged
glaucia86 merged 86 commits into
mainfrom
feat/migrate-swa-to-aca
Apr 24, 2025
Merged

feat: migrate from SWA to ACA#36
glaucia86 merged 86 commits into
mainfrom
feat/migrate-swa-to-aca

Conversation

@glaucia86
Copy link
Copy Markdown
Contributor

@glaucia86 glaucia86 commented Mar 4, 2025

Purpose

This pull request includes several changes to enhance the development environment, add deployment automation, and improve infrastructure management. The most important changes include updates to the development container configuration, the addition of environment variables, new GitHub workflows for deployment and validation, and the creation of a Dockerfile for building and running the application.

Development Environment Updates:

Environment Variables:

  • .env.example: Added environment variables for Azure OpenAI settings and optional Azure configurations.

Deployment Automation:

  • .github/workflows/azure-dev.yml: Added a workflow for deploying to Azure Container Apps, including steps for provisioning infrastructure and deploying the application.
  • deploy-to-aca.sh: Added a script for deploying the application to Azure Container Apps, including building the Docker image and configuring autoscaling.

Infrastructure Management:

  • infra/app/microblog-app.bicep: Added a Bicep template for deploying the application infrastructure, including managed identities, container apps, and environment variables.
  • infra/abbreviations.json: Added abbreviations for various Azure resources to streamline Bicep template writing.

Dockerfile:

  • Dockerfile: Created a multi-stage Dockerfile to build and run the application, optimizing for both development and production environments.

Does this introduce a breaking change?

[x] Yes
[ ] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@glaucia86 glaucia86 self-assigned this Mar 4, 2025
@glaucia86 glaucia86 added the enhancement New feature or request label Mar 4, 2025
glaucia86 added 27 commits March 4, 2025 20:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the project deployment from SWA to ACA by integrating Azure OpenAI services, enhancing the deployment process, and updating the infrastructure using Bicep templates.

  • Introduces new Azure resource definitions and retrieves OpenAI secrets in azure.yaml.
  • Adds a new GitHub workflow for deploying to Azure Container Apps and updates the CI workflow dependency installation command.
  • Updates import paths in the application code to reflect the new module location.

Reviewed Changes

Copilot reviewed 32 out of 47 changed files in this pull request and generated 1 comment.

File Description
azure.yaml Adds infrastructure configuration using Bicep templates and secret retrieval steps.
.github/workflows/azure-dev.yml Introduces a workflow for deploying to Azure Container Apps with enhanced subscription checks.
.github/workflows/ci.yml Modifies dependency installation and removes the installation of Azure Functions Core Tools.
app/routes/generate.tsx Updates the import path to reflect the module relocation of azureOpenAIService.
Files not reviewed (15)
  • .env.example: Language not supported
  • Dockerfile: Language not supported
  • deploy-to-aca.sh: Language not supported
  • infra/abbreviations.json: Language not supported
  • infra/app/containerapp.bicep: Language not supported
  • infra/core/ai/openai.bicep: Language not supported
  • infra/core/host/container-apps-environment.bicep: Language not supported
  • infra/core/monitoring/app-insights.bicep: Language not supported
  • infra/core/monitoring/log-analytics.bicep: Language not supported
  • infra/core/registry/container-registry.bicep: Language not supported
  • infra/core/security/keyvault.bicep: Language not supported
  • infra/core/security/managed-identity.bicep: Language not supported
  • infra/main.bicep: Language not supported
  • infra/main.parameters.json: Language not supported
  • package.json: Language not supported

Comment thread .github/workflows/ci.yml Outdated
- Deleted unused Bicep modules for container apps environment, Application Insights, Log Analytics, and Key Vault.
- Consolidated monitoring resources into a shared module for better management.
- Introduced new shared modules for Cognitive Services, Key Vault secrets, and dashboards.
- Updated main Bicep file to reflect changes in resource management and dependencies.
- Added support for conditional resource creation and improved parameter handling for Azure OpenAI resources.
- Enhanced Key Vault integration for storing sensitive information securely.
- Implemented role assignments for Azure resources to manage access control effectively.
Comment thread .github/workflows/validate-infra.yml Fixed
@github-advanced-security
Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Comment thread infra/shared/apps-env.bicep
}
properties: {
customSubDomainName: customSubDomainName
publicNetworkAccess: publicNetworkAccess

Check failure

Code scanning / templateanalyzer

Restrict Cognitive Service endpoints.

By default, public network access is enabled for a Cognitive Service account. Service Endpoints and Private Link can be leveraged to restrict access to PaaS endpoints. When access is restricted, access by malicious actor is from an unauthorized virtual network is mitigated. Configure service endpoints and private links where appropriate.
}
properties: {
customSubDomainName: customSubDomainName
publicNetworkAccess: publicNetworkAccess

Check failure

Code scanning / templateanalyzer

Use Cognitive Service Private Endpoints.

By default, a public endpoint is enabled for Cognitive Services accounts. The public endpoint is used for all access except for requests that use a Private Endpoint. Access through the public endpoint can be disabled or restricted to authorized virtual networks. Data exfiltration is an attack where an malicious actor does an unauthorized data transfer. Private Endpoints help prevent data exfiltration by an internal or external malicious actor. They do this by providing clear separation between public and private endpoints. As a result, broad access to public endpoints which could be operated by a malicious actor are not required.
properties: {
customSubDomainName: customSubDomainName
publicNetworkAccess: publicNetworkAccess
networkAcls: networkAcls

Check failure

Code scanning / templateanalyzer

Restrict Cognitive Service endpoints.

By default, public network access is enabled for a Cognitive Service account. Service Endpoints and Private Link can be leveraged to restrict access to PaaS endpoints. When access is restricted, access by malicious actor is from an unauthorized virtual network is mitigated. Configure service endpoints and private links where appropriate.
customSubDomainName: customSubDomainName
publicNetworkAccess: publicNetworkAccess
networkAcls: networkAcls
disableLocalAuth: disableLocalAuth

Check failure

Code scanning / templateanalyzer

Use identity-based authentication for Cognitive Services accounts.

To send requests to Cognitive Services endpoints, each request must include an authentication header. Cognitive Services endpoints supports authentication with keys or tokens. Using an Azure AD token instead of a cryptographic key has some additional security benefits. With Azure AD authentication, the identity is validated against Azure AD identity provider. Using Azure AD identities centralizes identity management and auditing. Once you decide to use Azure AD authentication, you can disable authentication using keys.
name: name
location: location
tags: tags
properties: {

Check failure

Code scanning / templateanalyzer

Configure Azure Key Vault firewall.

By default, Key Vault accept connections from clients on any network. To limit access to selected networks, you must first change the default action. After changing the default action from Allow to Deny, configure one or more rules to allow traffic. Traffic can be allowed from: - Azure services on the trusted service list. - IP address or CIDR range. - Private endpoint connections. - Azure virtual network subnets with a Service Endpoint. If any of the following options are enabled you must also enable Allow trusted Microsoft services to bypass this firewall: - enabledForDeployment - Azure Virtual Machines for deployment. - enabledForDiskEncryption - Azure Disk Encryption for volume encryption. - enabledForTemplateDeployment - Azure Resource Manager for template deployment.
tenantId: subscription().tenantId
sku: { family: 'A', name: 'standard' }
enabledForTemplateDeployment: true
enableRbacAuthorization: false

Check warning

Code scanning / templateanalyzer

Use Azure role-based access control.

Azure RBAC is the recommended authorization system for the Azure Key Vault data plane. Azure RBAC allows users to manage key, secrets, and certificates permissions. It provides one place to manage all permissions across all Key Vaults. Azure RBAC for Key Vault also allows users to have separate permissions on individual keys, secrets, and certificates. The Azure RBAC permission model is not enabled by default.
tags: tags
sku: sku
properties: {
adminUserEnabled: adminUserEnabled

Check failure

Code scanning / templateanalyzer

Disable ACR admin user.

Azure Container Registry (ACR) includes a built-in local admin user account. The admin user account is a single user account with administrative access to the registry. This account provides single user access for early test and development. The admin user account is not intended for use with production container registries. Instead of using the admin user account, consider using Entra ID (previously Azure AD) identities. Entra ID provides a centralized identity and authentication system for Azure. This provides a number of benefits including: - Strong account protection controls with conditional access, identity governance, and privileged identity management. - Auditing and reporting of account activity. - Granular access control with role-based access control (RBAC). - Separation of account types for users and applications.
Copy link
Copy Markdown
Contributor Author

@glaucia86 glaucia86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glaucia86 glaucia86 requested a review from Copilot April 11, 2025 14:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 40 out of 55 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • .devcontainer/devcontainer.json: Language not supported
  • .dockerignore: Language not supported
  • .env.example: Language not supported
  • Dockerfile: Language not supported
  • deploy-to-aca.sh: Language not supported
  • infra/abbreviations.json: Language not supported
  • infra/app/microblog-app.bicep: Language not supported
  • infra/main.bicep: Language not supported
  • infra/main.parameters.json: Language not supported
  • infra/modules/fetch-container-image.bicep: Language not supported
  • infra/shared/apps-env.bicep: Language not supported
  • infra/shared/cognitiveservices.bicep: Language not supported
  • infra/shared/dashboard-web.bicep: Language not supported
  • infra/shared/keyvault-secret.bicep: Language not supported
  • infra/shared/keyvault.bicep: Language not supported

@glaucia86 glaucia86 requested a review from diberry April 24, 2025 15:51
@glaucia86 glaucia86 merged commit 551544a into main Apr 24, 2025
5 of 6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants