系列專欄:從 AWS 視角征服 Azure:AZ-900 30 天通關實戰
難度指數:★★★☆☆
核心考點:Azure Virtual Machines (IaaS 控制權與責任邊界)、VM 尺寸六大類型 (General purpose / Compute / Memory / Storage optimized / GPU / FPGA accelerated)、垂直擴展 Vertical Scaling (Scale Up / Down) vs 水平擴展 Horizontal Scaling (Scale Out / In)、可擴展性 Scalability vs 彈性 Elasticity、Virtual Machine Scale Sets (VMSS) 與 Autoscale 規則、Orchestration Mode (Flexible vs Uniform)、Availability Set 與容錯網域 Fault Domain / 更新網域 Update Domain、Availability Set (99.95%) vs Availability Zone (99.99%) 的 SLA 階梯、Azure Spot VM、Azure Virtual Desktop、Amazon EC2 ↔ Azure VM 對照、AWS Auto Scaling Group ↔ VMSS 對照、AWS SAA-C03 / CLF-C02 考題概念連動
本文使用了 kiro-cli (chatgpt 5.6 soul),gemini-3.6 flash,copilot cli ,進行,在openab 使用
Day 7 我們完成了 Phase 1 的地基驗收:責任邊界、管理範圍、故障粒度、工具定位四步排除法已經刻進反射動作。今天正式踏入 Phase 2:核心運算與網路要塞,而 Phase 2 的第一場戰役,就是雲端最古老、也最容易被輕視的服務——虛擬機器 (Virtual Machine)。
輕視它的代價通常出現在三個地方,這也是今天必須先建立的問題意識:
在 AWS 體系中,這三題你早就有答案:Amazon EC2 提供執行個體、EC2 Auto Scaling Group (ASG) 負責水平擴展、Multi-AZ 部署 負責資料中心級容錯、Placement Group 負責實體擺放策略。
今天 Day 8,我們要把這套 AWS 肌肉記憶精準地映射到 Azure:Virtual Machine ↔ EC2 Instance、VM Scale Sets ↔ Auto Scaling Group、Availability Set ↔ Spread Placement Group、Availability Zone ↔ Availability Zone,並且逐一用 Microsoft Learn 官方原文校正每一個 SLA 數字與名詞邊界。
以戰代訓課程在 Compute 章節開頭就下了一個非常好的定調(p74):Compute 服務都在回答同一件事——你的程式要在哪裡跑,以及你願意管理多少底層細節。 VM、App Service、Containers、Functions 不是誰比較高級,而是責任邊界畫在哪裡。
控制權 ▲ 管理負擔 ▲
│ │
┌───────┴──────────┬──────────────┬───────────────┬───────┴──────┐
│ Virtual Machine │ Containers │ App Service │ Functions │
│ (IaaS) │ (ACI / AKS) │ (PaaS) │ (Serverless) │
├──────────────────┼──────────────┼───────────────┼──────────────┤
│ 自選 OS 與版本 │ 打包執行環境 │ 平台代管 OS │ 事件才執行 │
│ 自裝任何軟體 │ 環境一致性 │ 只部署程式碼 │ 無流量零成本 │
│ 自負修補與防毒 │ 需懂映像管理 │ 不能改底層 OS │ 有執行時間限 │
├──────────────────┼──────────────┼───────────────┼──────────────┤
│ Azure: VM │ Azure: ACI / │ Azure: App │ Azure: │
│ │ AKS │ Service │ Functions │
├──────────────────┼──────────────┼───────────────┼──────────────┤
│ AWS: EC2 │ AWS: ECS/EKS │ AWS: App │ AWS: Lambda │
│ │ │ Runner │ │
└──────────────────┴──────────────┴───────────────┴──────────────┘
◀───── 控制越多、責任越多 管理越少、彈性越受限 ─────▶
💡 架構師重點筆記:這張圖的判斷邏輯只有一句話——先讀題目要控制什麼,再選服務。課程 p76 給的關鍵字對照非常精準:看到
install software、manage server、custom OS、lift and shift、legacy application→ Virtual Machine;看到host website、REST API、deploy code、managed hosting→ App Service(Day 9);看到package app with dependencies→ Containers(Day 10);看到event-driven、只在觸發時執行→ Functions(Day 9)。而看到autoscale identical VMs、大量相同伺服器承接尖峰流量→ Virtual Machine Scale Sets,這正是今天的主角之一。
從 AWS 過來的架構師最容易低估的一點:在 Azure 建一台 VM,實際上是一次建立一整組互相關聯的資源,而每一個都有自己的計費與安全含意。Microsoft Learn 的 VM 總覽 明確列出這組「支援資源」:
| Azure 隨 VM 建立的資源 | 用途 | AWS 對照 | 計費/風險提醒 |
|---|---|---|---|
| Virtual Network / Subnet | 讓 VM 能與其他資源通訊 | VPC / Subnet | VNet 本身不收費,跨區流量收費(Day 11) |
| Network Interface Card (NIC) | 連接 VNet 的網卡 | ENI | 官方原文:"There's no separate cost for NICs",但數量上限依 VM 尺寸而定 |
| Private IP/(選用) Public IP | 內外部通訊 | Private / Elastic IP | ⚠️ 給 Public IP 就等於開放攻擊面,能不給就不給 |
| Network Security Group (NSG) | 控制進出 VM 的流量 | Security Group | 官方原文:"There are no additional charges for network security groups"(Day 12) |
| OS Disk + (選用) Data Disk | 系統碟與資料碟 | EBS Volume | 官方明確建議:"It's a best practice to keep your data on a separate disk from your operating system"(Day 16) |
| OS 授權(部分情境) | Windows Server 等授權成本 | 同 AMI 授權模型 | 可用 Azure Hybrid Benefit 降低(自帶授權) |
Learn:Azure VM 尺寸總覽 將所有尺寸依 Type(工作負載意圖) 分成六類,官方原文列舉為:"General purpose、Compute optimized、Memory optimized、Storage optimized、GPU accelerated、FPGA accelerated"。
| 類型 (Type) | 設計取向 | 典型 Azure 系列 | AWS 對照家族 |
|---|---|---|---|
| General purpose(一般用途) | 官方原文:"provide balanced CPU-to-memory ratio",適合開發測試、中小型資料庫、中低流量 Web | B / D 系列 | T / M 系列 |
| Compute optimized(計算最佳化) | 高 CPU:記憶體比,適合批次運算、應用伺服器 | F 系列 | C 系列 |
| Memory optimized(記憶體最佳化) | 高記憶體:CPU 比,適合大型記憶體資料庫、快取 | E / M 系列 | R / X 系列 |
| Storage optimized(儲存最佳化) | 高本機磁碟 IOPS/吞吐量,適合巨量資料與 NoSQL | L 系列 | I / D 系列 |
| GPU accelerated(GPU 加速) | 圖形渲染、深度學習訓練與推論 | N 系列(NC/ND/NV) | P / G 系列 |
| FPGA accelerated(FPGA 加速) | 可程式化硬體加速的特化工作負載 | NP 系列 | F1 執行個體 |
💡 架構師重點筆記(雙雲命名哲學差異):AWS 的執行個體型號是
家族 + 世代 + 大小(如m6i.2xlarge),型號本身就是規格;Azure 則是Standard_+ 家族字母 + vCPU 數 + 特性字母 + 版本(如Standard_D8s_v5,其中s= Premium Storage 支援、a= AMD、p= ARM 架構)。考試不會考型號,但會考「題目描述的工作負載該落在哪一類」——看到「記憶體內分析」選 Memory optimized,看到「深度學習訓練」選 GPU。
這四個名詞是 AZ-900 Describe Cloud Concepts 領域(占比 25–30%)的必考題,而且考法極為固定。先看官方逐字定義,再看記憶法。
Microsoft Learn 官方原文(Azure Monitor Autoscale 總覽):
"Autoscale scales in and out, or horizontally. Scaling horizontally is an increase or decrease of the number of resource instances. For example, for a virtual machine scale set, scaling out means adding more virtual machines. Scaling in means removing virtual machines."
"Autoscale does not support vertical scaling. In contrast, scaling up and down, or vertical scaling, keeps the same number of resource instances constant but gives them more capacity in terms of memory, CPU speed, disk space, and network. Vertical scaling is limited by the availability of larger hardware, which eventually reaches an upper limit... Vertical scaling might also require a restart of the VM during the scaling process."
繁體中文官方用詞也一併核實過(同頁 zh-tw 版):官方譯為「水平調整/水平擴展」「垂直調整」「向外/向內調整」「向上/向下調整」,並明寫「自動調整不支援垂直調整」。本文使用的中文名詞皆為官方翻譯,非自行意譯。
┌────────────────────────────────────────────────────────────────┐
│ 可擴展性 Scalability:容量能不能跟著需求長大(不一定自動) │
└────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌───────────────────────────┐ ┌───────────────────────────┐
│ 垂直擴展 Vertical Scaling │ │ 水平擴展 Horizontal │
│ = Scale Up / Scale Down │ │ = Scale Out / Scale In │
├───────────────────────────┤ ├───────────────────────────┤
│ 同「一台」變強/變弱 │ │ 「台數」變多/變少 │
│ D2s_v5 ──▶ D8s_v5 │ │ 2 台 ──▶ 20 台 │
│ 需重新部署,可能要重啟 │ │ 佈建新執行個體,不中斷 │
│ 受最大硬體規格上限限制 │ │ 可近乎無限延伸 │
│ ❌ Autoscale 不支援 │ │ ✅ Autoscale 原生支援 │
│ AWS:改 instance type │ │ AWS:Auto Scaling Group │
└───────────────────────────┘ └───────────────────────────┘
│ │
└────────────────┬───────────────────┘
▼
┌────────────────────────────────────────────────────────────────┐
│ 彈性 Elasticity:依「短期」需求自動增減資源(核心是「自動」) │
│ → 在 Azure 上的具體實作 = Autoscale + VM Scale Sets │
└────────────────────────────────────────────────────────────────┘
💡 架構師重點筆記(Why / Risk):為什麼官方特別強調「Autoscale 不支援垂直擴展」?因為 Azure Architecture Center:Autoscaling 講清了底層機制——"Vertical scaling often requires making the system temporarily unavailable while it's being redeployed. Therefore, it's less common to automate vertical scaling.";而水平擴展則是 "The application continues running without interruption as new resources are provisioned." 把自動化建立在「需要停機」的機制上,等於把服務中斷寫進自動化腳本,爆炸半徑會隨著觸發次數累積。這就是為什麼雲端原生架構一律優先設計成無狀態 + 水平擴展。
| 名詞 | 一句話定義 | 題幹關鍵字 | 常見干擾項 |
|---|---|---|---|
| 可擴展性 Scalability | 系統有能力增減容量以支援長期成長,不一定自動 | 「支援長期成長」「增加容量」 | 誤選 Elasticity |
| 彈性 Elasticity | 依短期需求自動增減資源,離峰自動縮減 | 「自動調整」「流量突然暴增」「離峰縮減」 | 誤選 Scalability |
| 垂直擴展 Vertical Scaling | 同一台資源加記憶體/加 CPU(Scale Up / Down) | 「adding memory or CPUs」「升級單一資源」 | 誤選 Agility 或 Elasticity |
| 水平擴展 Horizontal Scaling | 增加或移除執行個體數量(Scale Out / In) | 「add more VMs」「增加更多伺服器」 | 誤選 Vertical Scaling |
⚠️ 高頻陷阱:題目問「increase the computing capacity of a virtual machine by adding memory or CPUs」時,答案是 Vertical Scaling,不是 Elasticity(Elasticity 強調「自動」)、也不是 Agility(Agility 指「快速回應變化的能力」,是雲端效益而非擴展術語)。這正是 Part 3 真題 1 的原題設計。
這是今天最容易失分的一段。三個名詞都含「Availability」或「Set」,但解決的問題完全不同。以下每一項都附 Microsoft Learn 逐字原文。
Learn:可用性設定組總覽 官方原文:
"Availability sets are logical groupings of VMs that reduce the chance of correlated failures bringing down related VMs at the same time. Availability sets distribute VMs across multiple fault domains, improving reliability."
"The underlying Azure platform assigns an update domain and a fault domain to each virtual machine in your availability set. Each availability set can have up to 3 fault domains and 20 update domains. These settings can't be changed after the availability set is created."
"Fault domains define the group of virtual machines that share a common power source and network switch."
"Update domains indicate groups of virtual machines and underlying physical hardware that can be restarted at the same time.""Using two or more VMs in an availability set helps keep applications highly available and meets the 99.95% Azure service-level agreement (SLA)."
關鍵限制(考題陷阱來源),同一頁官方原文寫得毫不含糊:
"Availability sets are still susceptible to certain shared infrastructure failures, such as datacenter-level network outages, which can affect multiple fault domains."
"Availability sets provide high availability but don't offer the same level of resiliency as availability zones."
繁體中文官方頁面(zh-tw 版)使用的正式譯名為「可用性設定組」「容錯網域」「更新網域」,並同樣寫明「每個可用性設定組最多可以有 3 個容錯網域和 20 個更新網域」。
Learn:VM 可用性選項 官方原文:
"An Availability Zone is a physically separate zone, within an Azure region. There are three Availability Zones per supported Azure region. Each Availability Zone has a distinct power source, network, and cooling. By designing your solutions to use replicated VMs in zones, you can protect your apps and data from the loss of a data center."
而 SLA 的關鍵條件寫在 Learn:VM 總覽:
"Availability Zones are physically separated zones within an Azure region. Availability zones guarantee virtual machine connectivity to at least one instance at least 99.99% of the time when you have two or more instances deployed across two or more Availability Zones in the same Azure region."
⚠️ 極重要的反向陷阱:Learn:VM 可靠性 明確指出——"An individual VM can be deployed in a zonal configuration, which means that it's pinned to a single availability zone that you select. By itself, a zonal VM isn't resilient to zone outages." 以及 "If you don't configure a VM to be zonal, it's considered nonzonal or regional. Nonzonal VMs might be placed in any availability zone within the region." 「放進一個 AZ」不等於高可用;必須是「跨兩個以上 AZ、兩台以上執行個體」才拿得到 99.99%。
Learn:VMSS 總覽 官方原文:
"Azure Virtual Machine Scale Sets let you create and manage a group of load balanced virtual machine (VM) instances. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule."
四大官方列舉效益:"Easy to create and manage multiple VMs / Provides high availability and application resiliency by distributing VMs across availability zones or fault domains / Allows your application to automatically scale as resource demand changes / Works at large-scale"
而 Learn:VM 可用性選項 加了那句決定考題答案的話:
"Virtual machines in a scale set can also be deployed into multiple availability zones, a single availability zone, or regionally."
💡 架構師重點筆記(這句話就是 Part 3 真題 2 的答案來源):既然 Scale Set 可以部署成單一 AZ 或 regional,那麼題目只說「我把 VM 部署到一個(或兩個)Scale Set」而沒有指定跨 AZ時,就不能保證單一資料中心故障後服務存活。Scale Set 本身是「管理與擴展」機制,區域級容錯來自它「被設定成跨 AZ」這件事,不是來自 Scale Set 這個名詞。 這是最容易被 AWS 背景架構師誤判的地方——因為 AWS ASG 幾乎總是被教成要橫跨多個 Subnet(即多個 AZ),久了會誤以為「ASG 天生就是 Multi-AZ」。
| 部署方式 | Azure VM SLA | Learn 依據 | AWS 等價設計與其 SLA |
|---|---|---|---|
| 單一 VM(Premium SSD / Ultra Disk) | 99.9% | 單一執行個體層級承諾,無任何冗餘 | 單一 EC2 執行個體 → Instance-Level SLA 99.5% |
| 2 台以上 VM 在同一 Availability Set | 99.95% | "meets the 99.95% Azure service-level agreement" | Spread Placement Group(分散實體機架) |
| 2 台以上 VM 跨 2 個以上 Availability Zones | 99.99% | "guarantee virtual machine connectivity to at least one instance at least 99.99% of the time" | 跨 2 個以上 AZ 的 EC2 → Region-Level SLA 99.99% |
💡 雙雲 SLA 哲學對照(已逐字核實):AWS Compute SLA 原文寫明 "a Region-Level SLA that governs Amazon EC2 deployed across multiple AZs or regions",其中 "For Amazon EC2 with all running instances deployed concurrently across two or more AZs in the same region... a Monthly Uptime Percentage of at least 99.99%",而 "For each individual Amazon EC2 instance... an Instance-Level Uptime Percentage of at least 99.5%"。結論:兩朵雲的設計語言完全一致——可用性不是買來的,是「部署拓撲」換來的。 差別只在 Azure 多了一層 Availability Set(99.95%)這個「同資料中心內分散」的中間階梯,AWS 則以 Placement Group 策略處理相同問題但不給獨立 SLA 數字。
Learn:VMSS Orchestration Modes 官方原文:
"Flexible Orchestration is the recommended orchestration mode when deploying scale sets in Azure."(官方標題直接寫
Scale Sets with Flexible Orchestration (Recommended))⚠️ "The orchestration mode is defined when you create the scale set and cannot be changed or updated later."
| 面向 | Flexible Orchestration(官方建議) | Uniform Orchestration |
|---|---|---|
| 設計取向 | 官方原文:"Optimized for high availability and scalability with identical or mixed virtual machine types" | "Optimized for large-scale workloads with identical virtual machine instances" |
| 規模上限 | "enhanced availability guarantees (up to 1,000 VMs)" | 支援大規模同質執行個體 |
| API 相容性 | 可直接使用標準 Azure IaaS VM API | 官方明列限制:"lack compatibility with standard Azure IaaS VM API commands, Azure Resource Manager tagging, RBAC, Azure Backup, or Azure Site Recovery" |
| 混合執行個體 | 支援混用 VM 尺寸、混用 Spot + On-demand | 不支援混用 |
| 爆炸半徑提醒 | 建立後無法變更模式,選錯只能重建整組 Scale Set | 同上 |
💡 架構師重點筆記(重要的官方立場轉向):可用性設定組頁面現在掛著這段官方建議——"We recommend that customers choose Virtual Machine Scale Sets with flexible orchestration mode for high availability with the widest range of features.",而 Autoscale 頁面更直白:"Availability sets are an older scaling feature for virtual machines with limited support. We recommend migrating to Azure Virtual Machine Scale Sets for faster and more reliable autoscale support." 但請注意:Availability Set 仍是 AZ-900 現行考點(課程 p78 明列),且 99.95% SLA 仍然有效。「官方建議改用 VMSS」與「考試仍會考 Availability Set」兩件事同時為真,不要因為看到這句話就在考場上排除 Availability Set 選項。
Learn:Autoscale 總覽 有一組非常反直覺、但設計上完全合理的規則:
"Autoscale scales out if any of the rules are met. Autoscale scales in only if all the rules are met. In terms of logic operators, the OR operator is used for scaling out with multiple rules. The AND operator is used for scaling in with multiple rules."
💡 架構師重點筆記(Why):向外擴展用 OR(任一指標告急就加機器)、向內縮減用 AND(所有指標都閒置才敢減機器)——這是刻意設計的非對稱保守策略:加機器的代價只是錢,減錯機器的代價是服務中斷。AWS ASG 的 Target Tracking / Step Scaling 政策背後是同一套保守哲學,只是暴露的參數不同。官方另補一句可對照 AWS Predictive Scaling 的功能:"Predictive autoscale uses machine learning to help manage and scale Virtual Machine Scale Sets with cyclical workload patterns."
Learn:VM 可用性選項 原文:"There is no cost for the scale set itself, you only pay for each VM instance that you create.",同頁也寫 Availability Set "There is no cost for the Availability Set itself"。這兩個「編制容器」都免費,收費的永遠是實際跑起來的 VM 執行個體——與 AWS ASG 不收費、只收 EC2 費用完全一致。
課程把「以 VM 為基礎的相關服務」放在一起考,因為它們的差別是**「你要一台 VM、很多台自動擴展的 VM,還是要讓 VM 更可靠」**:
| 服務 | 解決什麼問題 | Learn 官方定位 | AWS 對照 |
|---|---|---|---|
| Virtual Machine | 單台雲端伺服器,最高控制權 | "you choose a virtual machine when you need more control over the computing environment" | EC2 Instance |
| VM Scale Sets | 一組可自動增減的負載平衡 VM | "a group of load balanced virtual machine instances" | Auto Scaling Group |
| Availability Set | 同資料中心內分散 FD / UD,抗機櫃故障 | 3 FD / 20 UD,99.95% SLA | Spread Placement Group |
| Availability Zone | 跨資料中心分散,抗機房級故障 | 2 台跨 2 AZ → 99.99% SLA | Multi-AZ 部署 |
| Azure Spot VM | 用閒置容量換大幅折扣,可被回收 | "there's no SLA for these VMs... the Azure infrastructure will evict Azure Spot Virtual Machines with 30-seconds notice"(Spot VM 文件) | EC2 Spot Instances |
| Azure Virtual Desktop (AVD) | 把 Windows 桌面與應用交給 Azure 執行,使用者從任何裝置連線 | 課程 p78 定位;虛擬桌面基礎架構 (VDI) | Amazon WorkSpaces |
⚠️ Spot VM 的爆炸半徑(Risk):官方原文明寫 "An Azure Spot Virtual Machine offers no high availability guarantees",且驅逐原則可設為
Deallocate(預設)或Delete——選Delete會連同底層磁碟一起刪除。把 Spot 放進有狀態的生產工作負載,等於在架構裡埋一顆 30 秒引信的炸彈。官方建議的適用場景是 "batch processing jobs, dev/test environments, large compute workloads"。
AZ-900 不會直接考實作,但這三點是「原廠最佳實踐」層級的必備知識,且每一項在考題中都以「哪個選項最安全」的形式出現過:
絕不硬編碼憑證(Never hardcode credentials)
自訂映像、Custom Script Extension、cloud-init 檔案裡塞連線字串或存取金鑰,是雲端最經典的資安破口。Azure 的正解是 Managed Identity + Azure Key Vault。Learn:Managed identities 總覽 原文:
"A common challenge for developers is the management of secrets, credentials, certificates, and keys... Manual handling of secrets and certificates are a known source of security issues and outages. Managed identities eliminate the need for developers to manage these credentials." 且 "A managed identity is an identity that can be assigned to an Azure compute resource (Azure Virtual Machine, Azure Virtual Machine Scale Set, ...)"、"You don't need to manage credentials. Credentials aren't even accessible to you."
管理連接埠不要暴露到 Internet(0.0.0.0/0 的 3389 / 22)
正解是 Azure Bastion。Learn:Bastion 總覽 原文:"Azure Bastion is a fully managed PaaS service that provides secure and seamless RDP/SSH connectivity to your virtual machines directly over TLS... When you connect via Azure Bastion, your virtual machines don't need a public IP address, agent, or special client software."
一致性靠 IaC,不靠 ClickOps
Day 5 已建立的觀念在這裡有具體代價:手動建 VM 最容易漏掉的就是「加入 Availability Set / 指定 Availability Zone」這個下拉選單——建完了看起來一切正常,帳單照付,但 SLA 從 99.99% 掉到 99.9% 而沒有任何錯誤訊息。用 Bicep / ARM Template 宣告 zones: ['1','2','3'] 或 Scale Set 的 zones 屬性,把可用性設計變成可被 Code Review 的一行程式碼,才是防止組態漂移 (Configuration Drift) 的唯一方法。
// Azure:Bicep — 跨 3 個 AZ 的 Flexible Scale Set(結構節錄)
param adminUsername string
@secure() // ← 機密一律用 @secure()
param adminPasswordOrKey string // 絕不硬編碼、不寫預設值
resource vmss 'Microsoft.Compute/virtualMachineScaleSets@2024-07-01' = {
name: 'vmss-titan-web-prod'
location: resourceGroup().location
zones: ['1', '2', '3'] // ← 跨 3 AZ ⇒ 99.99% SLA 前提
sku: { name: 'Standard_D2s_v5', capacity: 3 }
identity: { type: 'SystemAssigned' } // ← Managed Identity 取代帳密
properties: {
orchestrationMode: 'Flexible' // ← 官方建議,且建立後不可改
platformFaultDomainCount: 1 // ← 最大分散 (max spreading)
virtualMachineProfile: { /* OS 映像、NIC、磁碟、擴充功能 */ }
}
}
# AWS:CloudFormation — 等價的 Auto Scaling Group(結構節錄)
Resources:
TitanWebASG:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
MinSize: '3'
MaxSize: '20'
VPCZoneIdentifier: # ← 多個 Subnet = 多個 AZ
- !Ref PrivateSubnetAZa
- !Ref PrivateSubnetAZb
- !Ref PrivateSubnetAZc
LaunchTemplate: # ← 對照 VMSS virtualMachineProfile
LaunchTemplateId: !Ref TitanWebLaunchTemplate
Version: !GetAtt TitanWebLaunchTemplate.LatestVersionNumber
# IAM Role 透過 Launch Template 的 IamInstanceProfile 掛入(不放金鑰)
💡 架構師重點筆記(雙雲抽象機制的對稱與不對稱):
- 對稱處:兩邊都是「一份執行個體範本(
virtualMachineProfile↔LaunchTemplate)+ 一組容量參數 + 一組放置位置」。AZ 分散在 Azure 是zones陣列(直接宣告 AZ 編號),在 AWS 是VPCZoneIdentifier的 Subnet 清單(透過 Subnet 間接綁 AZ)——這就是 AWS 架構師最常在 Azure 踩空的地方:Azure 的 AZ 是 VM 的直接屬性,不是透過 Subnet 決定的。Azure 的 Subnet 不綁 AZ。(Day 11 詳解)- 不對稱處:VMSS 的
orchestrationMode建立後不可變更,這是 AWS ASG 沒有的一次性決策;反過來 AWS ASG 的MinSize/MaxSize直接寫在 ASG 上,Azure 則把容量上下限放在獨立的Microsoft.Insights/autoscalesettings資源裡。- 變更審查:部署前一律先跑
az deployment group what-if(對照 AWS Change Sets /terraform plan),確認不會意外把capacity降到 0 或替換掉整組執行個體。
┌───────────────────────────────────┬───────────────────────────────────┐
│ 🟠 AWS 運算與擴展生態系 │ 🔵 Azure 運算與擴展生態系 │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【IaaS 運算執行個體】 │ 【IaaS 運算執行個體】 │
│ Amazon EC2 Instance │ Azure Virtual Machine │
│ • AMI(映像) │ • Marketplace Image / 自訂映像 │
│ • m6i.2xlarge(型號即規格) │ • Standard_D8s_v5(家族+特性碼) │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【水平擴展與群組管理】 │ 【水平擴展與群組管理】 │
│ EC2 Auto Scaling Group (ASG) │ VM Scale Sets (VMSS) │
│ • Launch Template │ • virtualMachineProfile │
│ • Target Tracking / Step Scaling │ • Autoscale rules(OR 出/AND 入)│
│ • Predictive Scaling │ • Predictive autoscale │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【同機房內的實體分散】 │ 【同機房內的實體分散】 │
│ Spread Placement Group │ Availability Set │
│ • 分散到不同機架 │ • 3 Fault Domains(電源/交換器) │
│ • 無獨立 SLA 數字 │ • 20 Update Domains(維護重啟) │
│ │ • 2 台以上 ⇒ 99.95% SLA │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【跨資料中心容錯】 │ 【跨資料中心容錯】 │
│ Multi-AZ(靠 Subnet 綁 AZ) │ Availability Zones(VM 直接屬性)│
│ • 跨 2 AZ ⇒ Region SLA 99.99% │ • 2 台跨 2 AZ ⇒ 99.99% SLA │
│ • 單一執行個體 ⇒ 99.5% │ • 單一 VM(Premium SSD) ⇒ 99.9% │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【折扣型可中斷容量】 │ 【折扣型可中斷容量】 │
│ EC2 Spot Instances │ Azure Spot VM │
│ • 2 分鐘中斷通知 │ • 30 秒驅逐通知、無 SLA │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【免公有 IP 的安全管理通道】 │ 【免公有 IP 的安全管理通道】 │
│ SSM Session Manager │ Azure Bastion(RDP/SSH over TLS)│
├───────────────────────────────────┼───────────────────────────────────┤
│ 【運算資源的身分憑證】 │ 【運算資源的身分憑證】 │
│ EC2 Instance Profile / IAM Role │ Managed Identity │
│ Secrets Manager / Parameter Store│ Azure Key Vault │
├───────────────────────────────────┼───────────────────────────────────┤
│ 【雲端虛擬桌面 VDI】 │ 【雲端虛擬桌面 VDI】 │
│ Amazon WorkSpaces │ Azure Virtual Desktop (AVD) │
└───────────────────────────────────┴───────────────────────────────────┘
💡 架構師重點筆記(三個最容易搞錯的映射):
- AZ 綁定方式不同:AWS 的 EC2 落在哪個 AZ,是由你選的 Subnet 決定的;Azure 的 VM 落在哪個 AZ,是 VM 自己的
zones屬性決定的,Azure Subnet 不綁 AZ。從 AWS 過來若沿用「選 Subnet 就等於選 AZ」的直覺,會建出一整組全部落在同一個 AZ(甚至 nonzonal)的 VM。- Availability Set 在 AWS 沒有完全等價物:它是 Azure 特有的「同資料中心內、由平台自動分配 FD / UD」的抽象層,最接近的是 Spread Placement Group,但 AWS 不為它提供獨立的 SLA 數字。
- VMSS ≠ ASG 的完全複製:VMSS 多了一個 AWS 沒有的一次性不可變決策(
orchestrationMode),且 Uniform 模式的執行個體不支援標準 VM API、ARM Tag、RBAC、Azure Backup 與 Site Recovery——這在成本分攤與備份治理上是實質限制。
| 決策維度 | AWS 服務 / 機制 | Azure 服務 / 機制 | 架構決策剖析 |
|---|---|---|---|
| 需要完整控制 OS | Amazon EC2 | Azure Virtual Machine | 題幹關鍵字:custom OS、install software、lift and shift、legacy application。控制權最高,OS 修補與防毒責任也回到客戶身上。 |
| 大量同質機器承接尖峰 | EC2 Auto Scaling Group | VM Scale Sets | 題幹關鍵字:identical VMs、autoscale、尖峰流量。核心價值是「集中管理 + 自動增減」,容錯要另外靠 AZ 設定。 |
| 加大單機規格 | 更改 instance type | 調整 VM Size(Scale Up) | 兩邊都需停機/重新部署,兩邊的自動擴展服務都不做這件事。 |
| 同機房抗硬體故障 | Spread Placement Group | Availability Set | Azure 提供 3 FD / 20 UD 的平台自動分配,並綁定 99.95% SLA。 |
| 抗整座機房故障 | 跨 2+ AZ 部署 | 跨 2+ Availability Zones | 兩邊都必須「2 台以上 + 跨 2 區以上」才拿到 99.99%。 |
| 極低延遲的機器間通訊 | Cluster Placement Group | Proximity Placement Group | ⚠️ 兩者都會降低容錯:Learn 原文警告 "proximity placement means that an outage of the datacenter can affect all of the VMs in the group"。 |
| 可中斷的批次運算 | EC2 Spot Instances | Azure Spot VM | 都無高可用保證。Azure 為 30 秒驅逐通知,並可選 Deallocate 或 Delete 原則。 |
| 免公有 IP 的維運通道 | SSM Session Manager | Azure Bastion | 都消除「為了 SSH 而開 Public IP」這個攻擊面。 |
| 短期大量開關的開發測試機 | 自建 ASG + 排程 Lambda | Azure DevTest Labs | Learn 定位:"quickly create and manage Azure virtual machines for development and testing",內建成本控管與自動關機原則。這是 Part 3 真題 5 的陷阱核心。 |
| 雲端虛擬桌面 | Amazon WorkSpaces | Azure Virtual Desktop | 課程 p78 明列為 VM 相關服務之一。 |
只列 Day 8 新出現的名詞。Availability Zone / Region / Region Pair 已於 Day 2 介紹、共同責任模型與 IaaS 定義已於 Day 7 介紹、ARM Template / Bicep 已於 Day 5 介紹,此處不重複。
full control、custom OS、install software、lift and shift 就選 VM;但同時代表 OS 修補、防火牆設定與安全維護的責任仍在客戶身上。adding memory or CPUs 的標準答案。需重啟、有硬體上限、Azure Autoscale 不支援。add more VMs 的標準答案,也是 Autoscale 唯一支援的維度。Day 6 我們幫 Titan 科技建立了健康監控與成本顧問機制,Day 7 完成了地基驗收。現在真正的戰役來了:Titan 科技的全球電商平台要在三週後迎接雙十一,這次要從零設計運算層。
CTO 把你叫進作戰室,攤開四張需求卡:
CTO:「架構師,這次我要一次把運算層做對,不要再讓我半夜接電話。四個需求,一次交清:
- 前端 Web 層:平日只需要 3 台機器,雙十一當天預估要 20 台以上,而且要自動增減,不要有人守著 Portal 手動點。活動結束後必須自己縮回去,我不想付一整個月的 20 台費用。
- 可用性硬要求:Web 層必須拿到 99.99% 的 VM SLA,而且要用最少的機器數與最少的區域數達成——我不想為了漂亮的數字多付錢。
- 交易資料庫叢集:因為叢集節點間的同步有嚴格的低延遲要求,法務與 DBA 都堅持必須留在同一座資料中心內。但我還是要求:那座資料中心裡某個機櫃跳電、或微軟排定平台維護重啟時,叢集不能整組同時掛掉。
- 資安鐵律:資安長剛被稽核釘過。所有機器不准有對外的 3389 / RDP 連接埠,維運人員要能安全登入;而且應用程式連資料庫與儲存體時,不准在任何映像、腳本或範本裡出現帳號密碼或存取金鑰。
給我方案,並且告訴我為什麼其他做法不行。」
【Titan 科技雙十一運算層作戰圖】
│
┌──────────────┬────────────┴─────────┬──────────────────┐
▼ ▼ ▼ ▼
【需求 1】 【需求 2】 【需求 3】 【需求 4】
3 ⇄ 20 台 99.99% SLA 低延遲同機房 零公開 RDP
自動增減 最少機器/區域 但要抗機櫃故障 零硬編碼憑證
│ │ │ │
[水平擴展] [跨 AZ 拓撲] [FD / UD 分散] [身分與通道]
以下四個方案,哪一個同時滿足全部四項需求,且符合 Azure 原生最佳實踐與最小成本原則?
方案 A:
方案 B:
zones: ['1','2'] 跨兩個可用性區域,初始 3 台、Autoscale 規則依 CPU 在 3–20 台之間自動 Scale Out / In。@secure()。方案 C:
方案 D:
需求 1(3 ⇄ 20 台自動增減)→ VMSS + Autoscale
這是教科書級的水平擴展 (Scale Out / In) 情境。Learn 官方對 VMSS 的定義正是 "The number of VM instances can automatically increase or decrease in response to demand or a defined schedule"。而選 Flexible orchestration 的理由有三:官方明訂它是建議模式、支援標準 VM API(Tag / RBAC / Backup 都能用,成本分攤與備份治理不會被卡)、且未來若要混用 Spot 與隨需執行個體也留有餘地。
Scale Set 本身不收費("There is no cost for the scale set itself"),活動結束自動縮回 3 台就只付 3 台的錢,完全命中 CTO「不想付一整月 20 台」的要求。
需求 2(99.99% + 最少機器與區域)→ 2 台 × 2 個 AZ
Learn 原文的條件是 "two or more instances deployed across two or more Availability Zones in the same Azure region"。注意 CTO 說的是「最少」——所以答案是 2 台 + 2 個 AZ,不是 3 台或 3 個 AZ。方案 B 的初始容量 3 台跨 2 個 AZ 已經滿足並超過門檻,SLA 條件在 Autoscale 縮到最低 3 台時依然成立。
⚠️ 這裡有個常被忽略的維運陷阱:如果你把 Autoscale 的
minimum設成 1,那麼在離峰時段這套架構會掉出 99.99% SLA 的適用條件。SLA 條件是「持續」的,不是「曾經部署過」。設定最小容量時,下限必須 ≥ 2 且橫跨 ≥ 2 個 AZ。
需求 3(同機房低延遲 + 抗機櫃故障)→ Availability Set
這題的限制條件(必須同一座資料中心)直接排除了 Availability Zone。Availability Set 正是為此設計:平台自動把 VM 分散到最多 3 個 Fault Domain("share a common power source and network switch",防機櫃跳電)與 20 個 Update Domain("can be restarted at the same time",且*"only one update domain is restarted at a time"*,防維護重啟全滅)。額外好處是 Learn 明載 "Availability sets provide lower VM-to-VM latency than availability zones because the VMs are placed in closer physical proximity"——低延遲需求也一併滿足。
誠實揭露此設計的殘餘風險:官方同時警告 "Availability sets are still susceptible to certain shared infrastructure failures, such as datacenter-level network outages"。所以正確的架構師行為是——採用方案 B,但在架構決策紀錄 (ADR) 中明確標註「資料庫層的殘餘風險是資料中心級故障,此風險由低延遲需求換來,需以跨區域備份/Azure Site Recovery 補位」,而不是假裝這個風險不存在。
需求 4(零公開 RDP + 零硬編碼憑證)→ Bastion + Managed Identity + Key Vault
Bastion 官方原文:"your virtual machines don't need a public IP address";Managed Identity 官方原文:"You don't need to manage credentials. Credentials aren't even accessible to you." 兩者合起來把「攻擊面」與「機密外洩面」同時歸零。範本中的密碼參數標記 @secure() 則確保值不會被寫進部署歷史記錄。
方案 A 陷阱(四個錯誤全中):
方案 C 陷阱(每一項都是似是而非的「常見誤解」):
zones 就是 regional,Learn 另處補刀:"Nonzonal VMs might be placed in any availability zone within the region. If any availability zone in the region experiences an outage, nonzonal VMs might be in the affected zone and can experience downtime." 這正是 Part 3 真題 2 的考點。platformFaultDomainCount 控制),不存在「把 Scale Set 執行個體塞進 Availability Set」這種疊加操作。這是把兩個相似名詞誤當成可堆疊功能的典型症狀。方案 D 陷阱:
本段共 5 題:真題 1–3 透過
examtopics-az900-searchskill 定位並以 headless 瀏覽器讀取討論頁的data-answers-tally真實票數(不採用頁面上的靜態百分比樣板),再逐一與 Microsoft Learn 交叉驗證;真題 4–5 取自 2020 年 gratisexam 111 題歷史題庫,已過「已知過期考點」篩檢。全部改寫為 Titan 科技情境,引用來源一律指向 Microsoft Learn。
Titan 科技的財報結算系統跑在一台 Azure 虛擬機器上。每季結算時,DBA 發現該 VM 的記憶體與 CPU 全部滿載,於是把它的尺寸從 Standard_D2s_v5 調整為 Standard_D16s_v5,讓同一台機器獲得更多記憶體與 vCPU。請問這個動作對應的正確術語是什麼?
data-answers-tally 實測),最高讚同留言(rrfatesingh,37 upvotes)與次高(phuctran,24 upvotes,Selected Answer: B)、Stasheck(11 upvotes)都明確支持 B。但確實存在反對意見:留言者 petebear55 主張答案應為 A (agility),理由是題目問的是「WHICH TERM(哪一個術語)」而非「哪一種擴展方式」,認為這是刻意誤導的紅鯡魚;另一名 aramosme 附議「Agility is correct」。兩者各僅 1 upvote,論據薄弱且與官方定義衝突,但由於原題英文措辭確實不夠精確,這