This guide covers deploying the Three Rivers Bank Credit Card application to Azure using Azure Developer CLI (azd) with Terraform.
- Azure Subscription: Ensure you have an active Azure subscription
- Service Principal: Create a service principal for GitHub Actions
- Resource Permissions: Ensure permissions to create resources in your subscription
# Clone the repository
git clone <repository-url>
cd three-rivers-bank
# Login to Azure
az login
# Initialize azd
azd initTerraform IaC is already located under infra/terraform/ (the standard azd layout for Terraform). If you want azd to pick up the default environment setting, copy the azd config:
mkdir -p .azd
cp azd-config.json .azd/config.json# Provision infrastructure and deploy applications
azd up
# Or run steps individually:
azd provision # Deploy infrastructure only
azd deploy # Deploy applications only# Create a new environment
azd env new <environment-name>
# List environments
azd env list
# Set active environment
azd env select <environment-name>
# View environment variables
azd env get-values- Create Service Principal:
az ad sp create-for-rbac --name "three-rivers-bank-github" \
--role contributor \
--scopes /subscriptions/{subscription-id} \
--sdk-auth-
Add Repository Secrets in GitHub:
AZURE_CLIENT_ID: From service principal outputAZURE_CLIENT_SECRET: From service principal outputAZURE_TENANT_ID: Your Azure tenant IDAZURE_SUBSCRIPTION_ID: Your Azure subscription IDAZURE_CREDENTIALS: Full JSON output from service principal creation
-
Add Repository Variables:
AZURE_CLIENT_ID: Same as secret (for OIDC)AZURE_TENANT_ID: Same as secret (for OIDC)AZURE_SUBSCRIPTION_ID: Same as secret (for OIDC)
The repository includes azure-azd-deploy.yml which provides:
- Environment Selection: Deploy to dev/staging/production via workflow_dispatch
- Path Filtering: Only runs when relevant code changes (backend/, frontend/, docker/, infra/)
- Validation: Terraform fmt and validate checks before deployment
- Smoke Tests: Automated health checks after deployment
- Validate: Terraform format check and validation
- Build and Test: Compiles backend (Maven) and frontend (npm), runs unit tests and E2E tests with Playwright
- Deploy: Uses
azd provisionandazd deployfor infrastructure and application deployment - Smoke Tests: Verifies backend health and API endpoints
- Cleanup: Optional cleanup on failure for dev environment
- Resource Group: Contains all resources
- Container Registry: Stores application container images
- Container App Environment: Managed environment for container apps
- Log Analytics Workspace: Centralized logging
- Container Apps: Backend (Spring Boot) and Frontend (React/Nginx)
- Container Apps: Auto-scaling from 1-3 replicas based on load
- Container Registry: Basic tier for development
- Log Analytics: 30-day retention to minimize costs
# View application logs
azd logs --service backend
azd logs --service frontend
# Or use Azure CLI
az containerapp logs show --name <backend-app-name> --resource-group <rg-name># Scale manually (temporary)
az containerapp revision set-mode --name <app-name> --resource-group <rg-name> --mode single
az containerapp update --name <app-name> --resource-group <rg-name> --min-replicas 2 --max-replicas 5- Frontend URL:
https://<frontend-app-name>.azurecontainerapps.io - Backend API:
https://<backend-app-name>.azurecontainerapps.io - Backend Health:
https://<backend-app-name>.azurecontainerapps.io/actuator/health
-
azd command not found:
- Install Azure Developer CLI:
winget install Microsoft.Azd
- Install Azure Developer CLI:
-
Authentication failures:
az login --use-device-code azd auth login
-
Container image build failures:
- Ensure Docker is running
- Check Dockerfile paths in azure.yaml
-
Terraform state issues:
# Reset Terraform state (use cautiously) cd infra/terraform terraform init -reconfigure
-
Resource naming conflicts:
- Azure resource names must be globally unique
- The template uses random suffixes to avoid conflicts
# Check azd configuration
azd config list
# Verify infrastructure state
azd show
# Check environment variables
azd env get-values
# View detailed deployment logs
azd deploy --debug# Delete entire environment
azd down --purge
# Or delete specific services
azd down --service backend
azd down --service frontendIf azd cleanup fails, manually delete via Azure Portal or CLI:
# Delete resource group (removes all resources)
az group delete --name <resource-group-name> --yes --no-wait- Container Registry: Admin access enabled for azd deployment
- HTTPS Only: All container apps configured with HTTPS ingress
- Environment Variables: Sensitive values stored as container app secrets
- Network: Container apps communicate over private network within environment
- Logging: Application logs sent to Log Analytics workspace
- Custom Domain: Configure custom domain for frontend application
- SSL Certificates: Add custom SSL certificates
- API Management: Add Azure API Management for enhanced API security
- Key Vault: Store application secrets in Azure Key Vault
- Application Insights: Add detailed application monitoring
- Azure Front Door: Add CDN and global load balancing
- Azure Developer CLI: Documentation
- Azure Container Apps: Documentation
- Terraform Azure Provider: Documentation