AI Solution Architect: from System Analyst to AI Architect
บทที่ 7/12

APIs, Cloud-native & Integration

Cloud-native on Azure

Building blocks ของระบบ cloud-native ตั้งแต่ landing zone, containers และ serverless compute, private networking และ Entra ID, resilience patterns อย่าง retry, circuit breaker และ multi-region, availability math และ reference architecture ของ GenAI app บน Azure

⏱ ประมาณ 35 นาที

Cloud-native ไม่ได้แปลว่า “lift-and-shift ขึ้น cloud” แต่หมายถึง design ให้ใช้จุดแข็งของ cloud คือ autoscaling, managed services, infrastructure as code และ design for failure เพราะ components ล้มได้เสมอ บทนี้อธิบาย concepts แบบ vendor-neutral ก่อน แล้ว map เข้ากับ Azure (ชื่อ services ณ ปี 2026)

Landing zone: build the foundation first

องค์กรใหญ่ไม่ให้แต่ละทีมสร้าง subscription ตามใจ แต่เตรียม landing zone ไว้ก่อน คือ foundation กลางที่กำหนดไว้แล้ว

  • Management groups และ subscriptions แยกตาม environment (dev, test, prod)
  • Network แบบ hub-and-spoke มี firewall และ connectivity กับ on-premises data center ที่ hub
  • Azure Policy enforce rules เช่น ห้ามสร้าง resources นอก allowed regions ห้ามเปิด public endpoints
  • Centralized identity, logging และ cost management

Solution architect มักไม่ได้สร้าง landing zone เอง แต่ต้อง design ให้อยู่ใน guardrails ของมัน ได้

Choosing compute

Optionลักษณะเหมาะกับ
Azure Functionsserverless, event-driven, pay-per-useงานสั้น ๆ ตาม events เช่น process document ที่ upload
Azure Container Appsmanaged containers, autoscale (scale to zero ได้)APIs และ orchestrators ส่วนใหญ่ ทีมไม่อยากดูแล Kubernetes
Azure Kubernetes Service (AKS)Kubernetes เต็มรูปแบบองค์กรที่มี platform team และต้องการ fine-grained control
App Servicemanaged web/API hostingweb apps แบบดั้งเดิม

Networking & identity

Private endpoint ให้ PaaS services เช่น Azure OpenAI, AI Search และ Storage มี private IP ภายใน virtual network แล้ว ปิด public network access customer data จึงวิ่งใน private network เป็น baseline requirement ของงานธนาคาร

Microsoft Entra ID (เดิมชื่อ Azure Active Directory) จัดการ identity ทั้งคนและ workloads หลักสำคัญคือใช้ managed identity ให้ app authenticate กับ services อื่นโดย ไม่มี keys หรือ passwords ในโค้ด ส่วน secrets ที่หลีกเลี่ยงไม่ได้เก็บใน Key Vault

Resilience patterns

Patternแก้ปัญหาข้อควรระวัง
Timeoutrequest ค้างไม่สิ้นสุดตั้งทุก network call
Retry with backofftransient errors (เช่น HTTP 429, 503)exponential backoff + jitter และ retry เฉพาะ idempotent requests
Circuit breakerdownstream ล่มนาน retry ซ้ำ ๆ ยิ่งทำให้แย่เมื่อ fail ติดกันเกิน threshold ให้ “open circuit” ตอบด้วย fallback ทันที แล้วทดลองใหม่เป็นระยะ
Fallbackprimary service ใช้ไม่ได้เช่น LLM ล่ม → “กำลังโอนสายให้พนักงาน”
Multi-regionทั้ง region ล่มcost เกือบ 2 เท่า, data replication และต้องอยู่ใน regions ที่ regulation อนุญาต

สำหรับ LLM โดยเฉพาะ HTTP 429 (quota exceeded) เกิดบ่อยมาก AI gateway จึงมัก load balance ไปหลาย deployments หรือหลาย regions และ failover ไปตัวสำรองเมื่อตัวหลักเต็ม

Availability math

เมื่อ request ต้องผ่านหลาย components in series availability รวมคือ ผลคูณ

Atotal=A1×A2×⋯A_\text{total} = A_1 \times A_2 \times \cdots

เช่น app 99.9% เรียก LLM 99.95% → 0.999 × 0.9995 ≈ 0.9985 หรือ 99.85% ต่ำกว่าทุก component ที่นำมาต่อกัน

เมื่อมีสองชุด in parallel (ระบบยังทำงานถ้าชุดใดชุดหนึ่งยังอยู่)

Atotal=1−(1−A)2A_\text{total} = 1 - (1 - A)^2

เช่น สอง regions region ละ 99.9% → 1 − 0.001² = 0.999999 ในทางทฤษฎี (ในความจริงต่ำกว่านี้ เพราะสอง regions มักล้มด้วย common cause ได้ เช่น deploy โค้ดที่มี bug)

แปลงเป็น downtime 99.9% ต่อเดือน 30 วัน ยอม downtime ได้ 0.1% × 30 × 24 × 60 = 43.2 นาที ตัวเลขนี้ช่วยให้ executives เห็นภาพว่า “อีกหนึ่งเลข 9” มี cost เท่าไร

Reference architecture: GenAI app on Azure

Reference architecture ของ GenAI app บน Azure ณ ปี 2026: user เข้าผ่าน Azure Front Door กับ WAF ไปยัง app บน Container Apps ซึ่งเรียก Azure OpenAI ผ่าน API Management ที่เป็น AI gateway และ retrieve documents จาก Azure AI Search ที่ index ข้อมูลจาก Data Lake ทั้งหมดอยู่ใน virtual network ที่ใช้ private endpoints ส่วน Entra ID, managed identity, Key Vault และ Azure Monitor ใช้ร่วมกันทุก layer
Standard design ที่ทีมใหม่ควรเริ่มจาก แล้วปรับตาม requirements
Layerหน้าที่Azure services
Edgeload balancing, web attack protectionFront Door หรือ Application Gateway + WAF
App & orchestratorRAG และ agent logicContainer Apps หรือ AKS
AI gatewaytoken quota, load balancing, loggingAPI Management
ModelsLLM และ embeddingsAzure OpenAI ใน Microsoft Foundry
Knowledgeindex และ document searchAzure AI Search + Blob Storage หรือ Data Lake
Securityidentity, secrets, private networkEntra ID, managed identity, Key Vault, private endpoints
Observabilitylogs, traces, metrics, costAzure Monitor, Application Insights

แบบทดสอบ

ต้องการให้ app เรียก Azure OpenAI โดย data ไม่วิ่งผ่าน public internet ควรใช้อะไร
วิธีใดให้ app authenticate กับ Azure AI Search โดยไม่มี secrets อยู่ในโค้ดเลย
Downstream ล่มมา 10 นาทีแล้ว และ retries ทำให้ระบบช้าลงทั้งหมด ควรใช้ pattern ใด

ระบบที่มี availability 99.5% ต่อเดือน (30 วัน) ยอม downtime ได้กี่นาที

สาม components ต่อกัน in series แต่ละตัวมี availability 99.9% availability รวมประมาณเท่าใด