EngineeringSolution ArchitectAzure Architecture

Session 01 - Azure Well-Architected Framework

Tổng quan

Azure Well-Architected Framework (WAF) cung cấp 5 pillars giúp đánh giá và cải thiện chất lượng kiến trúc cloud. Đây là kim chỉ nam cho mọi architecture decision trên Azure.

5 Pillars - Tóm tắt

PillarMục tiêu chínhKey Metric
ReliabilityKhả năng phục hồi từ failure và tiếp tục hoạt độngSLA/SLO uptime %, RTO, RPO
SecurityBảo vệ data, application, infrastructureZero-trust compliance score
Cost OptimizationTối ưu chi phí mà không hy sinh chất lượngCost per transaction, waste %
Operational ExcellenceQuy trình vận hành, monitoring, CI/CDMTTR, deployment frequency
Performance EfficiencyĐáp ứng demand hiệu quả với resource allocationP95 latency, throughput

Chi tiết từng Pillar

Reliability

Nguyên tắc cốt lõi:

  • Design for failure - mọi component đều có thể fail
  • Sử dụng Availability Zones và multi-region khi SLA yêu cầu
  • Implement retry pattern với exponential backoff
  • Health endpoint monitoring

Checklist thực hành:

  • Định nghĩa SLA/SLO cho từng service
  • Implement circuit breaker pattern (Polly library)
  • Sử dụng Azure Load Balancer / Application Gateway
  • Setup disaster recovery với paired regions
  • Test failover định kỳ (Chaos Engineering)
csharp
// Retry policy với Polly - áp dụng cho HttpClient
builder.Services.AddHttpClient("ExternalApi")
    .AddPolicyHandler(Policy
        .HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)
        .WaitAndRetryAsync(3, attempt =>
            TimeSpan.FromSeconds(Math.Pow(2, attempt))));

Security

Nguyên tắc cốt lõi:

  • Zero Trust - never trust, always verify
  • Defense in depth - nhiều layer bảo vệ
  • Least privilege access
  • Encrypt data at rest và in transit

Checklist thực hành:

  • Enable Microsoft Defender for Cloud
  • Sử dụng Managed Identity thay vì connection string
  • Enable Private Endpoints cho PaaS services
  • Implement RBAC với custom roles khi cần
  • Key Vault cho secrets management
  • Enable diagnostic logging cho audit

Cost Optimization

Nguyên tắc cốt lõi:

  • Right-size resources dựa trên actual usage
  • Tận dụng Reserved Instances cho stable workloads
  • Sử dụng auto-scaling thay vì over-provisioning
  • Tag mọi resource để track cost

Checklist thực hành:

  • Setup Azure Cost Management budgets + alerts
  • Review Azure Advisor cost recommendations hàng tuần
  • Implement auto-shutdown cho dev/test environments
  • Evaluate serverless cho bursty workloads
  • Sử dụng Spot VMs cho batch processing

Operational Excellence

Nguyên tắc cốt lõi:

  • Infrastructure as Code (Bicep/Terraform)
  • Automate everything - CI/CD, testing, monitoring
  • Implement observability (logs, metrics, traces)
  • Blameless postmortem culture

Checklist thực hành:

  • IaC cho toàn bộ infrastructure (Bicep preferred)
  • CI/CD pipeline với automated testing
  • Centralized logging với Log Analytics
  • Runbooks cho incident response
  • Regular architecture reviews

Performance Efficiency

Nguyên tắc cốt lõi:

  • Scale out thay vì scale up khi có thể
  • Caching strategy (Redis, CDN, in-memory)
  • Async processing cho long-running operations
  • Database performance tuning

Checklist thực hành:

  • Load testing với Azure Load Testing / k6
  • Implement distributed caching (Azure Cache for Redis)
  • Sử dụng Azure Service Bus cho async messaging
  • CDN cho static content
  • Database indexing và query optimization

Azure Advisor Integration

Azure Advisor tự động scan resources và đưa ra recommendations theo 5 pillars.

bash
# Lấy danh sách recommendations từ Azure Advisor
az advisor recommendation list \
  --output table

# Filter theo category
az advisor recommendation list \
  --category Cost \
  --output table

# Export recommendations sang JSON để review
az advisor recommendation list \
  --output json > advisor-report.json

Well-Architected Review Process

Quy trình thực hiện WAR:

  1. Xác định scope - chọn workload cần review (1 application hoặc 1 service)
  2. Chạy WAF Assessment - sử dụng Azure Well-Architected Review tool ↗
  3. Phân tích kết quả - mỗi pillar sẽ có score và recommendations
  4. Ưu tiên - dùng impact/effort matrix để chọn quick wins trước
  5. Implement - tạo backlog items, gắn vào sprint
  6. Đo lường - so sánh score trước/sau

Practical Example - E-Commerce Application

ConcernPillarSolution
Trang sản phẩm chậm khi traffic caoPerformanceAzure CDN + Redis Cache + auto-scale App Service
Payment data exposure riskSecurityPrivate Endpoint cho SQL + Key Vault + WAF
Monthly bill tăng 40%CostRight-size VMs + Reserved Instances + auto-shutdown dev
Deploy thủ công gây downtimeOperationalBlue-green deployment via Azure DevOps
Database mất data khi outageReliabilityGeo-replication + automated backup + failover group

Bicep - Tagging Strategy cho WAF Tracking

bicep
// Gắn tag WAF pillar vào resource group để track compliance
resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = {
  name: 'rg-ecommerce-prod'
  location: 'southeastasia'
  tags: {
    environment: 'production'
    'waf-reliability': 'tier-1'
    'waf-security': 'compliant'
    'cost-center': 'engineering'
    owner: 'platform-team'
  }
}

Trade-off Analysis

Trade-offThiên về AThiên về B
Reliability vs CostMulti-region active-active ($$$$)Single region + backup ($)
Security vs PerformanceEncrypt everything, strict NSG (slower)Minimal encryption (faster)
Operational Excellence vs SpeedFull IaC + CI/CD (slow setup)Manual deploy (fast start)

Nguyên tắc: Không có kiến trúc hoàn hảo - chỉ có kiến trúc phù hợp với business requirements và budget. WAF giúp bạn đánh giá trade-offs một cách có hệ thống.