LAB 14 ~2.5 giờ Module 15 Agent-based Migration

Migrate Physical Servers lên Azure

Migrate physical server (bare-metal, không có hypervisor) lên Azure bằng Azure Migrate với phương pháp agent-based replication: cài replication appliance, mobility service agent trên server nguồn, cấu hình replication và thực hiện migration.

🎯 Mục Tiêu Lab

Phân biệt agent-based vs agentless migration và biết khi nào dùng phương pháp nào

Tạo Azure Migrate project và cấu hình replication appliance (Ser01)

Cài đặt Mobility Service agent trên physical server cần migrate (Ser02)

Cấu hình replication từ Ser02 lên Azure qua appliance Ser01

Thực hiện test migration và verify ứng dụng hoạt động trên Azure

Hoàn tất production migration và assign public IP để verify công khai

🏗️ Kịch Bản & Tài Nguyên

Công ty bạn có một physical server (Ser02) chạy IIS web server tại datacenter nội bộ. Server này không chạy trên hypervisor nào — đây là bare-metal server thực sự. Azure Migrate sẽ dùng phương pháp agent-based để replicate toàn bộ disk lên Azure.

Ser01 — Replication Appliance
  • • IP: 192.168.1.3/24
  • • Role: Configuration Server + Process Server
  • • OS: Windows Server 2019
  • • Kết nối internet để đăng ký Azure
Ser02 — Physical Server (Nguồn)
  • • IP: 192.168.1.4/24
  • • OS: Windows Server 2019 + IIS
  • • RDP enabled (NLA disabled)
  • • Default IIS site đang chạy
Azure Target
  • • RG: PhysicalRG (southeastasia)
  • • VNet: VnetPhysical (192.168.1.0/24)
  • • NSG: PhysicalNSG (port 80, 3389)
  • • VM size: Standard_D2_v2
Luồng Agent-Based Replication
Ser02 (Physical)          Ser01 (Appliance)           Azure
┌─────────────────┐       ┌──────────────────┐       ┌──────────────────┐
│  Mobility Agent │──────▶│ Config Server    │──────▶│  Recovery Vault  │
│  (cài trên Ser02│  TCP  │ Process Server   │ HTTPS │  Storage Account │
│  port 9443)     │       │ (đóng gói data)  │       │  (replicated VM) │
└─────────────────┘       └──────────────────┘       └──────────────────┘

📋 Chuẩn Bị

Yêu cầu:
  • Azure subscription với Contributor role
  • Ser01: Windows Server 2019, kết nối internet, 8vCPU/16GB RAM
  • Ser02: Windows Server 2019 + IIS, RDP port 3389 mở, NLA tắt
  • Ser01 và Ser02 có thể kết nối TCP với nhau (port 9443)
So sánh Agentless vs Agent-based:
  • Agentless (Hyper-V/VMware): không cần cài agent, dùng hypervisor API — đơn giản hơn
  • Agent-based (Physical/other): cần cài Mobility Service trên từng server nguồn — linh hoạt hơn

🧪 Các Bước Thực Hiện

1

Tạo Infrastructure Azure & Azure Migrate Project

Cách 1 — Azure Portal
  1. 1.1Portal → Resource groups → + Create → PhysicalRG, Southeast Asia
  2. 1.2Tạo VNet: VnetPhysical, address: 192.168.1.0/24, subnet: sub1 (192.168.1.0/24)
  3. 1.3Tạo NSG: PhysicalNSG → Inbound rules: Allow TCP 80 (priority 100), Allow TCP 3389 (priority 200)
  4. 1.4Gắn NSG vào subnet sub1 của VnetPhysical
  5. 1.5Portal → Azure Migrate → Create project → RG: PhysicalRG, Name: MigratePhysicaltoAzure, Geography: Asia Pacific
Cách 2 — Azure CLI
Azure CLI— Tạo toàn bộ infrastructure Azure
# Tạo Resource Group
az group create \
  --name PhysicalRG \
  --location southeastasia \
  --tags "lab=14" "module=az104"

# Tạo VNet và subnet
az network vnet create \
  --resource-group PhysicalRG \
  --name VnetPhysical \
  --address-prefix 192.168.1.0/24 \
  --subnet-name sub1 \
  --subnet-prefix 192.168.1.0/24 \
  --location southeastasia

# Tạo NSG
az network nsg create \
  --resource-group PhysicalRG \
  --name PhysicalNSG \
  --location southeastasia

# Thêm inbound rule cho HTTP
az network nsg rule create \
  --resource-group PhysicalRG \
  --nsg-name PhysicalNSG \
  --name Allow-HTTP \
  --priority 100 \
  --protocol Tcp \
  --destination-port-range 80 \
  --access Allow

# Thêm inbound rule cho RDP
az network nsg rule create \
  --resource-group PhysicalRG \
  --nsg-name PhysicalNSG \
  --name Allow-RDP \
  --priority 200 \
  --protocol Tcp \
  --destination-port-range 3389 \
  --access Allow

# Gắn NSG vào subnet
az network vnet subnet update \
  --resource-group PhysicalRG \
  --vnet-name VnetPhysical \
  --name sub1 \
  --network-security-group PhysicalNSG

# Đăng ký provider Azure Migrate
az provider register --namespace Microsoft.Migrate
az provider register --namespace Microsoft.OffAzure
2

Cài Đặt Replication Appliance trên Ser01

Replication appliance đóng vai trò Configuration Server và Process Server: nhận data từ Mobility Agent trên Ser02, nén, mã hóa, và gửi lên Azure. Đây là thành phần trung tâm của agent-based replication.

Cách 1 — Azure Portal + Thao tác trên Ser01
  1. 2.1Azure Migrate → Migration tools → Discover → Are your machines virtualized? → "Not Virtualized/Other"
  2. 2.2Tải file MicrosoftAzureSiteRecoveryUnifiedSetup.exe → copy sang Ser01
  3. 2.3Tải key file .VaultCredentials → copy sang Ser01 (dùng để đăng ký với Azure)
  4. 2.4Trên Ser01: chạy setup file → chọn "Install the configuration server and process server"
  5. 2.5Choose connectivity: "Connect directly to Azure Site Recovery without a proxy server"
  6. 2.6Vault credentials: chọn file .VaultCredentials đã tải → đăng ký thành công
  7. 2.7Lưu passphrase hiển thị sau khi cài xong — sẽ cần khi đăng ký Mobility Agent
  8. 2.8Thêm credentials của Ser02: tên admin account dùng để push cài Mobility Agent
PowerShell-CMD (Windows)— Chạy trên Ser01 để lấy passphrase
# Lấy passphrase sau khi cài appliance (chạy trên Ser01)
cd "C:\ProgramData\ASR\home\svsystems\bin"
.\genpassphrase.exe -v

# Output: hiển thị passphrase dạng chuỗi ký tự
# Lưu passphrase này — cần khi cấu hình Mobility Agent trên Ser02
3

Cài Mobility Service Agent trên Ser02 (Server Nguồn)

Mobility Service là agent chạy trên physical server cần migrate. Agent này capture disk changes theo thời gian thực và gửi về Ser01 (Process Server) để forward lên Azure.

Cách 1 — Thao tác trên Ser02
  1. 3.1Copy thư mục C:\ProgramData\ASR\home\svsystems\pushinstallsvc\repository\ từ Ser01 → Ser02 (chứa installer)
  2. 3.2Trên Ser02: đổi tên file installer và cài đặt
  3. 3.3Chạy UnifiedAgent.exe với tham số Silent mode
  4. 3.4Cấu hình agent trỏ về Ser01 với passphrase đã lưu
PowerShell-CMD (Windows)— Chạy trên Ser02
# Bước 1: Đổi tên installer (thay * bằng tên file thực tế)
ren Microsoft-ASR_UA*Windows*release.exe MobilityServiceInstaller.exe

# Bước 2: Extract installer
MobilityServiceInstaller.exe /q /x:C:\TempExtracted

# Bước 3: Vào thư mục extracted
cd C:\TempExtracted

# Bước 4: Cài Mobility Service agent (silent mode)
.\UnifiedAgent.exe /Role "MS" /Silent

# Bước 5: Cấu hình agent trỏ về Ser01
# Thay [IP_SER01] bằng IP thực của Ser01 (192.168.1.3)
# Thay [PASSPHRASE_FILE_PATH] bằng đường dẫn file passphrase
.\UnifiedAgentConfigurator.exe /CSEndPoint 192.168.1.3 /PassphraseFilePath C:\passphrase.txt

# Kiểm tra service đã chạy
sc query InMage Scout Application Service
Kết quả (Output)— Mobility Service cài thành công
SERVICE_NAME: InMage Scout Application Service
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

# Sau đó Ser02 sẽ xuất hiện trong Azure Migrate → Discovered servers
4

Cấu Hình Replication & Chờ Protected Status

Cách 1 — Azure Portal
  1. 4.1Azure Migrate → Migration tools → Replicate → Not Virtualized/Other
  2. 4.2On-premises appliance: chọn Ser01 (Configuration Server vừa đăng ký)
  3. 4.3Process Server: chọn Ser01 (cùng máy đóng vai Process Server)
  4. 4.4Machines to migrate: chọn Ser02 (192.168.1.4) → Next
  5. 4.5Target settings: Subscription, RG: PhysicalRG, VNet: VnetPhysical, Subnet: sub1
  6. 4.6VM size: Standard_D2_v2, OS disk type: Premium SSD, Azure Hybrid Benefit: Yes → Replicate
  7. 4.7Monitoring → Status column → chờ chuyển sang "Protected" (~15-30 phút)
Kết quả (Output)— Replication status
Replicating machines:
Name     Status       Health    Progress    Last sync
----     ------       ------    --------    ---------
Ser02    Protected    Healthy   100%        2 minutes ago

Recovery points available:
- Latest crash-consistent:   2 minutes ago
- Latest app-consistent:     6 hours ago
5

Test Migration & Production Migration

Cách 1 — Azure Portal
Test Migration:
  1. 5.1Replicating machines → Ser02 → Test migration → VNet: VnetPhysical → Test migration
  2. 5.2Chờ ~5-10 phút → VM Ser02-test tạo trong PhysicalRG
  3. 5.3Gán Public IP Standard → RDP verify OS → mở browser trỏ vào IP → kiểm tra IIS default page
  4. 5.4Clean up test migration → xóa VM test, giữ replication
Production Migration:
  1. 5.5Tắt Ser02 on-premises để đảm bảo data nhất quán
  2. 5.6Replicating machines → Ser02 → Migrate → Shutdown: Yes → Migrate
  3. 5.7Chờ ~5-10 phút → VM xuất hiện trong PhysicalRG
Azure CLI— Gán Public IP sau migration và verify
# Tạo Public IP Standard SKU
az network public-ip create \
  --resource-group PhysicalRG \
  --name pip-ser02-migrated \
  --sku Standard \
  --allocation-method Static \
  --location southeastasia

# Gán vào NIC của VM (thay tên NIC thực tế)
az network nic ip-config update \
  --resource-group PhysicalRG \
  --nic-name <TÊN_NIC_SER02> \
  --name ipconfig1 \
  --public-ip-address pip-ser02-migrated

# Lấy Public IP
PUBIP=$(az network public-ip show \
  --resource-group PhysicalRG \
  --name pip-ser02-migrated \
  --query ipAddress -o tsv)
echo "Public IP: $PUBIP"

# Verify web server qua curl
curl -I http://$PUBIP

# Xem VM status
az vm show \
  --resource-group PhysicalRG \
  --name Ser02 \
  --query "{provisioningState:provisioningState, powerState:powerState}" \
  --show-details -o table
Kết quả (Output)— curl verify IIS
HTTP/1.1 200 OK
Content-Length: 703
Content-Type: text/html
Last-Modified: Tue, 21 May 2026 10:00:00 GMT
Accept-Ranges: bytes
ETag: "xxxxxxxxxx"
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Wed, 21 May 2026 12:00:00 GMT

# IIS default page trả về 200 OK — migration thành công!

🧹 Dọn Dẹp Tài Nguyên

Azure CLI— Xóa tài nguyên lab
# Stop replication trong Portal trước:
# Azure Migrate → Replicating machines → Ser02 → Stop replication

# Sau đó xóa RG
az group delete --name PhysicalRG --yes --no-wait

# Xóa Azure Migrate project (nếu cần)
az group delete --name MigrateServerRG --yes --no-wait

# Kiểm tra
az group list --output table | grep -i physical

📊 Kết Quả Đầu Ra Lab 14

Infrastructure Azure chuẩn bị xong

PhysicalRG, VnetPhysical, PhysicalNSG với rules HTTP/RDP

Replication Appliance đăng ký thành công

Ser01 hiển thị là Configuration Server trong Azure Migrate

Mobility Agent cài thành công

InMage Scout service RUNNING trên Ser02, Ser02 xuất hiện trong discovered servers

Replication Protected

Ser02 status: Protected, Health: Healthy, replication 100%

IIS verify qua Public IP

curl http://<public-ip> → HTTP 200 OK, Server: Microsoft-IIS/10.0

Migration hoàn tất

VM Ser02 chạy trong Azure, phát triển tiếp trên cloud

❓ Câu Hỏi Ôn Tập

1. Tại sao physical server migration bắt buộc phải dùng agent-based, không thể agentless như Hyper-V?

Gợi ý: Agentless dựa vào hypervisor API (VMware vCenter, Hyper-V WMI) để snapshot disk. Physical server không có hypervisor nên phải dùng agent cài trực tiếp trên OS để capture disk changes.

2. Vai trò của Configuration Server và Process Server trong agent-based replication? Chúng có thể đặt trên cùng một máy không?

Gợi ý: Config Server: quản lý configuration, xác thực. Process Server: nhận data từ agent, cache, compress, mã hóa, gửi Azure. Lab này đặt cả hai trên Ser01 — phù hợp cho lab/small scale.

3. Passphrase trong Azure Migrate agent-based replication dùng để làm gì? Điều gì xảy ra nếu mất passphrase?

Gợi ý: Passphrase dùng để xác thực Mobility Agent với Configuration Server — đảm bảo chỉ server được phép mới kết nối. Mất passphrase → phải reinstall appliance.

4. Azure Hybrid Benefit khi migrate physical server Windows mang lại lợi ích gì? Điều kiện nào để áp dụng?

Gợi ý: Sử dụng lại Windows Server license on-premises với Software Assurance để không phải trả phí license Windows trên Azure VM — tiết kiệm ~40% chi phí VM.

5. So sánh quy trình migrate Physical Server (Lab 14) với Hyper-V VM (Lab 12). Điểm giống và khác nhau?

Gợi ý: Giống: cùng Azure Migrate project, replication → test migration → production migration. Khác: Physical cần cài Mobility Agent trên server nguồn; Hyper-V cần cài SiteRecoveryProvider trên host. Physical dùng "Not Virtualized" selection.

Lab 13: Azure Site Recovery Thư viện Labs Lab 15: Service Endpoints
Zalo