LAB 12 ~2 giờ Module 13 Azure Migrate

Migrate Virtualized Servers lên Azure

Migrate VM từ môi trường on-premises (VMware/Hyper-V) lên Azure bằng Azure Migrate: cài đặt appliance, discovery máy ảo, đánh giá (assessment), replication dữ liệu, và thực hiện cutover production.

🎯 Mục Tiêu Lab

Tạo Azure Migrate project và hiểu kiến trúc tổng thể của công cụ migration

Cài đặt Azure Migrate Appliance trên Hyper-V host để discovery VM on-premises

Thực hiện assessment để đánh giá sẵn sàng migration và chi phí Azure

Cấu hình replication VM từ on-premises lên Azure (agentless với Hyper-V)

Thực hiện test migration để xác nhận VM hoạt động đúng trước cutover

Hoàn tất production migration (cutover) và gán public IP để verify

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

Công ty bạn đang chạy web server trên Hyper-V VM on-premises tại datacenter nội bộ. Nhiệm vụ: migrate VM đó lên Azure mà không thay đổi cấu hình ứng dụng (lift-and-shift). Azure Migrate là công cụ hiện hành của Microsoft để thực hiện toàn bộ quy trình này.

Môi trường On-Premises
  • • Hyper-V Host: Windows Server 2019
  • • Guest VM: Windows Server 2019 + IIS
  • • Network: 192.168.1.0/24
  • • RDP port 3389 enabled (NLA off)
Tài Nguyên Azure
  • • Resource Group: rg-migrate-lab12
  • • Azure Migrate Project: migrate-lab12
  • • Region: southeastasia
  • • VNet đích: vnet-migrate-target
Thời Gian
  • • Setup & Discovery: ~30 phút
  • • Assessment: ~15 phút
  • • Replication: ~20-30 phút
  • • Migration & verify: ~20 phút

📋 Chuẩn Bị

Yêu cầu môi trường:
  • Azure subscription active (contributor role)
  • Hyper-V host chạy Windows Server 2016/2019
  • Guest VM có IIS hoặc web service đang chạy
  • Hyper-V host kết nối internet (để đăng ký appliance)
Lưu ý quan trọng:
  • Azure Migrate thay thế hoàn toàn Azure Site Recovery cho migration workflow
  • Hyper-V agentless: không cần cài agent trên guest VM
  • Luôn tắt VM nguồn trước cutover để tránh mất dữ liệu
  • Xóa resource group sau lab để tránh phát sinh chi phí

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

1

Tạo Resource Group & Azure Migrate Project

Cách 1 — Azure Portal
  1. 1.1Portal → Resource groups → + Create → Name: rg-migrate-lab12, Region: Southeast Asia → Review + Create
  2. 1.2Portal → tìm kiếm "Azure Migrate" → Click vào dịch vụ → Create project
  3. 1.3Subscription: chọn subscription của bạn → Resource group: rg-migrate-lab12
  4. 1.4Project name: migrate-lab12 → Geography: Asia Pacific → Create
  5. 1.5Sau khi tạo xong, vào project → thấy 3 phần: Discovery & assessment, Migration tools, Business case
Cách 2 — Azure CLI
Azure CLI— Bash / Cloud Shell / PowerShell
# Đăng nhập nếu chưa
az login

# Tạo Resource Group
az group create \
  --name rg-migrate-lab12 \
  --location southeastasia \
  --tags "lab=12" "module=az104" "owner=hoatranlab"

# Đăng ký provider Azure Migrate (nếu chưa đăng ký)
az provider register --namespace Microsoft.Migrate
az provider register --namespace Microsoft.OffAzure

# Kiểm tra trạng thái đăng ký
az provider show --namespace Microsoft.Migrate --query "registrationState"

# Tạo Azure Migrate Project qua REST API (CLI không có lệnh trực tiếp)
# Dùng az rest để gọi API
az rest \
  --method PUT \
  --uri "https://management.azure.com/subscriptions/$(az account show --query id -o tsv)/resourceGroups/rg-migrate-lab12/providers/Microsoft.Migrate/migrateProjects/migrate-lab12?api-version=2018-09-01-preview" \
  --body '{"location":"southeastasia","properties":{}}'
2

Cài Đặt Azure Migrate Appliance trên Hyper-V Host

Azure Migrate Appliance là một VM nhỏ chạy trên Hyper-V host, đóng vai trò gateway thu thập thông tin các VM và gửi metadata lên Azure. Đây là bước cốt lõi của quy trình discovery agentless.

Cách 1 — Azure Portal
  1. 2.1Vào Azure Migrate project → Discovery & assessmentDiscover
  2. 2.2Are your machines virtualized? → chọn "Yes, with Hyper-V"
  3. 2.3Download appliance: tải file VHD (~12GB) → copy sang Hyper-V host
  4. 2.4Trên Hyper-V host: Hyper-V Manager → Import Virtual Machine → chọn file VHD vừa tải → cấu hình 16GB RAM, 8 vCPU
  5. 2.5Start appliance VM → RDP vào → mở Azure Migrate Appliance Configuration Manager (tự mở sau khi boot)
  6. 2.6Paste Project key (copy từ Portal) → Verify → đăng nhập Microsoft Entra ID → Start discovery
  7. 2.7Chờ ~15-20 phút → Portal hiển thị "Hyper-V hosts: 1 (Connected)" và danh sách VMs được phát hiện
Lưu ý VMware:

Với VMware: tải OVA template thay vì VHD → deploy trên vCenter → cấu hình vCenter credentials trong Appliance Configuration Manager. Quy trình tương tự nhưng appliance kết nối với vCenter API thay vì Hyper-V WMI.

3

Tạo Assessment — Đánh Giá Sẵn Sàng Migration

Cách 1 — Azure Portal
  1. 3.1Azure Migrate → Assess → chọn Azure VM
  2. 3.2Assessment name: assess-lab12-hyperv
  3. 3.3Target location: Southeast Asia → Sizing criteria: As on-premises hoặc Performance-based
  4. 3.4Select machines: chọn VM cần migrate → Next → Create assessment
  5. 3.5Chờ ~5 phút → click vào assessment → xem: Azure readiness (Ready/Not ready), Monthly cost estimate, Recommended VM size
Kết quả (Output)— Assessment summary
Assessment: assess-lab12-hyperv
----------------------------------------
Total machines:          1
Azure VM readiness:      Ready (1)
Not ready:               0
Conditionally ready:     0

Recommended size:        Standard_D2s_v3
Monthly cost estimate:   ~$70 USD/month (Southeast Asia)
Storage:                 Premium SSD 64GB — ~$10/month

Azure Hybrid Benefit:    Enabled (Windows Server license)
4

Cấu Hình Replication (Nhân Bản Dữ Liệu)

Replication sao chép liên tục dữ liệu từ VM on-premises lên Azure. Với Hyper-V, Azure Migrate dùng AzureSiteRecoveryProvider cài trực tiếp trên Hyper-V host (không cần agent trên guest).

Cách 1 — Azure Portal
  1. 4.1Azure Migrate → Migration toolsReplicate
  2. 4.2Are your machines virtualized? → Yes, with Hyper-V
  3. 4.3Download AzureSiteRecoveryProvider.exe → chạy trên Hyper-V host → Install → đăng ký bằng key file tải từ Portal
  4. 4.4Chờ ~15 phút → Portal hiển thị "Registered Hyper-V hosts: 1 (Connected)"
  5. 4.5Chọn VM → cấu hình target: Resource group: rg-migrate-lab12, VNet: vnet-migrate-target, Subnet: default
  6. 4.6VM size: Standard_D2s_v3 → OS disk type: Premium SSD → Azure Hybrid Benefit: Yes → Replicate
  7. 4.7Monitoring → Replicating machines → chờ status chuyển sang "Protected" (~20-30 phút)
5

Test Migration — Kiểm Tra Trước Khi Cutover

Cách 1 — Azure Portal
  1. 5.1Replicating machines → chọn VM → Test migration
  2. 5.2Virtual network: chọn vnet-migrate-target → Test migration
  3. 5.3Chờ ~5-10 phút → Portal tạo VM test với suffix "-test"
  4. 5.4Vào VM test → gán Public IP tạm → RDP/HTTP để kiểm tra web server hoạt động đúng
  5. 5.5Sau khi verify → Clean up test migration để xóa VM test (không xóa replication)
Azure CLI— Gán Public IP để test
# Tạo Public IP Standard SKU cho VM test
az network public-ip create \
  --resource-group rg-migrate-lab12 \
  --name pip-vm-test \
  --sku Standard \
  --allocation-method Static \
  --location southeastasia

# Gán Public IP vào NIC của VM test (thay tên NIC phù hợp)
az network nic ip-config update \
  --resource-group rg-migrate-lab12 \
  --nic-name <TÊN_NIC_VM_TEST> \
  --name ipconfig1 \
  --public-ip-address pip-vm-test

# Lấy IP đã gán
az network public-ip show \
  --resource-group rg-migrate-lab12 \
  --name pip-vm-test \
  --query "ipAddress" -o tsv
6

Production Migration — Cutover Chính Thức

Quan trọng: Tắt VM on-premises trước khi migrate để đảm bảo dữ liệu nhất quán và tránh split-brain.
Cách 1 — Azure Portal
  1. 6.1Tắt VM on-premises trên Hyper-V Manager (Shutdown → không phải Power Off)
  2. 6.2Azure Migrate → Replicating machines → chọn VM → Migrate
  3. 6.3Shutdown machines before migration? → Yes → Migrate
  4. 6.4Chờ ~5-10 phút → VM xuất hiện trong resource group rg-migrate-lab12
  5. 6.5Gán Public IP → mở browser → truy cập http://<public-ip> → xác nhận web server hoạt động
  6. 6.6Azure Migrate → Stop replication → xác nhận migration hoàn tất
Azure CLI— Gán Public IP cho VM production
# Tạo Public IP cho VM production sau migrate
az network public-ip create \
  --resource-group rg-migrate-lab12 \
  --name pip-migrated-vm \
  --sku Standard \
  --allocation-method Static \
  --location southeastasia

# Gán vào NIC (thay tên VM/NIC tương ứng)
az network nic ip-config update \
  --resource-group rg-migrate-lab12 \
  --nic-name <TÊN_NIC_VM> \
  --name ipconfig1 \
  --public-ip-address pip-migrated-vm

# Xem IP và verify
az network public-ip show \
  --resource-group rg-migrate-lab12 \
  --name pip-migrated-vm \
  --query "ipAddress" -o tsv

# Kiểm tra VM running
az vm show \
  --resource-group rg-migrate-lab12 \
  --name <TÊN_VM_MIGRATE> \
  --query "provisioningState" -o tsv

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

Azure CLI— Xóa toàn bộ tài nguyên lab
# Xóa resource group lab (xóa tất cả resources bên trong)
az group delete \
  --name rg-migrate-lab12 \
  --yes \
  --no-wait

# Xác nhận RG đã được xóa
az group list --output table | grep migrate

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

Azure Migrate Project tạo thành công

Project hiển thị trong Portal với Discovery & assessment, Migration tools

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

Hyper-V hosts: 1 (Connected) — VM on-premises được discover

Assessment hoàn tất

Azure readiness: Ready — có VM size gợi ý và chi phí tháng

Replication trạng thái Protected

VM hiển thị Protected trong Replicating machines

Test migration thành công

VM test truy cập được qua HTTP/RDP, web server hoạt động bình thường

Production VM chạy trên Azure

VM migrate hiển thị trong rg-migrate-lab12, public IP accessible

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

1. Azure Migrate Appliance đóng vai trò gì trong quá trình migration? Có cần cài agent trên guest VM khi dùng Hyper-V không?

Gợi ý: Appliance là gateway discovery và replication. Hyper-V agentless — không cần agent trên guest. VMware cũng hỗ trợ agentless. Physical server cần agent (mobility service).

2. Tại sao phải tắt VM on-premises trước khi thực hiện final migration (cutover)?

Gợi ý: Tránh mất dữ liệu cuối, đảm bảo consistency — các thay đổi sau replication cuối sẽ không được đồng bộ nếu VM vẫn chạy khi cutover

3. Khác biệt giữa Test Migration và Final Migration là gì? Khi nào nên dùng Test Migration?

Gợi ý: Test tạo VM clone để validate, không ảnh hưởng replication. Final migration là cutover thật sự, dừng replication.

4. Azure Migrate Assessment cung cấp những thông tin gì hữu ích cho việc lập kế hoạch migration?

Gợi ý: Azure readiness, recommended VM size, monthly cost estimate, Azure Hybrid Benefit savings, dependency mapping

5. Sự khác biệt giữa migration Hyper-V và VMware trong Azure Migrate là gì?

Gợi ý: Hyper-V dùng VHD appliance + SiteRecoveryProvider trên host. VMware dùng OVA appliance + kết nối vCenter API. Cả hai đều agentless cho guest VM.

Lab 11: Azure Monitor & Alerts Thư viện Labs Lab 13: Azure Site Recovery
Zalo