LAB 05 AZ-500 ~45 phút Chương 02 Identity & Access

Bật MFA cho Nhóm Quản Trị Viên

Tạo Conditional Access policy yêu cầu MFA cho nhóm admin có đặc quyền cao. Thực hành Report-only mode, loại trừ break-glass account, kiểm tra với What If tool trước khi bật policy thật.

🎯 Mục Tiêu Lab

Tạo security group GRP-AZ500-PrivilegedAdmins và thêm admin lab

Tạo Conditional Access policy yêu cầu MFA khi truy cập Azure Portal

Chạy policy ở chế độ Report-only và phân tích sign-in log

Loại trừ break-glass account khỏi policy để tránh bị khóa

Kiểm tra policy bằng What If tool trước khi bật thật

Bật policy On và xác minh admin bị yêu cầu MFA khi đăng nhập

📋 Chuẩn Bị

Yêu cầu:
  • Azure subscription đang hoạt động
  • Quyền Global Administrator hoặc Conditional Access Administrator
  • Đã hoàn thành Lab 01–04 (có user và group lab)
  • Microsoft Entra ID P1 hoặc P2 license (cần cho Conditional Access)
Lưu ý quan trọng:
  • Luôn loại trừ break-glass account trước khi bật policy
  • Dùng Report-only mode để test trước khi bật thật
  • Nếu trial tenant không có P2 license, dùng Security Defaults tham khảo
  • Break-glass account KHÔNG nên gán bất kỳ CA policy nào

🏗️ Kịch Bản

Công ty HoaTranLab Corp vừa bị tấn công credential stuffing vào tài khoản admin. Security team yêu cầu bắt buộc MFA cho tất cả thành viên nhóm GRP-AZ500-PrivilegedAdmins khi truy cập Azure Portal. Bạn là Azure Security Engineer cần triển khai Conditional Access policy, chạy thử Report-only 24h, dùng What If để mô phỏng tác động, sau đó bật policy chính thức.

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

1

Tạo Group GRP-AZ500-PrivilegedAdmins và Break-glass Account

Cách 1 — Portal
  1. 1.1Vào Entra ID → Groups → New group
  2. 1.2Group type: Security, Name: GRP-AZ500-PrivilegedAdmins
  3. 1.3Thêm các admin user vào group → Create
  4. 1.4Tạo user break-glass: [email protected] — mật khẩu dài 20+ ký tự, lưu vault ngoại tuyến
Cách 2 — Azure CLI
Azure CLI / Cloud Shell
# Tạo security group cho privileged admins
az ad group create \
  --display-name "GRP-AZ500-PrivilegedAdmins" \
  --mail-nickname "GRP-AZ500-PrivilegedAdmins"

# Lấy Object ID của group vừa tạo
GROUP_ID=$(az ad group show \
  --group "GRP-AZ500-PrivilegedAdmins" \
  --query id -o tsv)
echo "Group ID: $GROUP_ID"

# Lấy Object ID user admin lab và thêm vào group
USER_ID=$(az ad user show \
  --id "[email protected]" \
  --query id -o tsv)
az ad group member add \
  --group "GRP-AZ500-PrivilegedAdmins" \
  --member-id $USER_ID

# Xác nhận membership
az ad group member list \
  --group "GRP-AZ500-PrivilegedAdmins" \
  --query "[].{Name:displayName, UPN:userPrincipalName}" \
  --output table
Kết quả bước 1: Group GRP-AZ500-PrivilegedAdmins xuất hiện trong Entra ID Groups. Break-glass user tạo thành công, chưa gán bất kỳ role hay policy nào.
2

Tạo Conditional Access Policy — Report-only Mode

Cách 1 — Portal (chính)
  1. 2.1Entra ID → Security → Conditional Access → New policy
  2. 2.2Name: CA-AZ500-RequireMFA-PrivilegedAdmins
  3. 2.3Users: Include → Groups → chọn GRP-AZ500-PrivilegedAdmins
  4. 2.4Exclude: Users and groups → chọn break-glass account az500-breakglass
  5. 2.5Target resources: Cloud apps → Select apps → Microsoft Azure Management
  6. 2.6Grant: Grant access → Require multifactor authentication → Select
  7. 2.7Enable policy: chọn Report-only → Save
Cách 2 — Microsoft Graph PowerShell
Microsoft Graph PowerShell — Requires Identity.SignIn.ReadWrite.All permission
# Kết nối Graph với quyền cần thiết
Connect-MgGraph -Scopes "Policy.ReadWrite.ConditionalAccess","Group.Read.All"

# Lấy Group Object ID
$groupId = (Get-MgGroup -Filter "DisplayName eq 'GRP-AZ500-PrivilegedAdmins'").Id
$breakGlassId = (Get-MgUser -Filter "UserPrincipalName eq '[email protected]'").Id

# Tạo CA policy ở chế độ Report-only
$params = @{
    displayName = "CA-AZ500-RequireMFA-PrivilegedAdmins"
    state = "enabledForReportingButNotEnforced"   # Report-only mode
    conditions = @{
        users = @{
            includeGroups = @($groupId)
            excludeUsers  = @($breakGlassId)       # Exclude break-glass
        }
        applications = @{
            includeApplications = @("797f4846-ba00-4fd7-ba43-dac1f8f63013") # Azure Management
        }
    }
    grantControls = @{
        operator = "OR"
        builtInControls = @("mfa")
    }
}
New-MgIdentityConditionalAccessPolicy -BodyParameter $params
Write-Host "CA policy created in Report-only mode"
Kết quả bước 2: Policy CA-AZ500-RequireMFA-PrivilegedAdmins xuất hiện trong danh sách CA policies với trạng thái Report-only. Break-glass account đã được loại trừ.
3

Kiểm Tra Sign-in Log và Sử Dụng What If Tool

Cách 1 — Portal (chính)
  1. 3.1Đăng nhập bằng az500-admin01 vào portal.azure.com
  2. 3.2Entra ID → Monitoring → Sign-in logs → tìm đăng nhập của admin01
  3. 3.3Click vào sign-in event → tab Conditional Access → xem policy report: Success / Failure / Not applied
  4. 3.4What If: Conditional Access → What If → nhập User = az500-admin01, App = Microsoft Azure Management → run
  5. 3.5Xác nhận policy hiển thị trong kết quả What If với Grant = Require MFA
Cách 2 — Microsoft Graph PowerShell
Microsoft Graph PowerShell
# Xem sign-in logs gần nhất của admin user
Connect-MgGraph -Scopes "AuditLog.Read.All"

$userId = (Get-MgUser -Filter "UserPrincipalName eq '[email protected]'").Id

Get-MgAuditLogSignIn `
  -Filter "userId eq '$userId'" `
  -Top 5 |
  Select-Object CreatedDateTime, UserPrincipalName,
    @{N="AppDisplayName";E={$_.AppDisplayName}},
    @{N="CAResult";E={$_.ConditionalAccessStatus}} |
  Format-Table -AutoSize
4

Bật Policy — Chuyển từ Report-only sang On

Cách 1 — Portal
  1. 4.1Conditional Access → chọn policy CA-AZ500-RequireMFA-PrivilegedAdmins
  2. 4.2Enable policy → chuyển từ Report-only sang On → Save
  3. 4.3Đăng nhập bằng az500-admin01 → xác nhận bị prompt MFA
  4. 4.4Đăng nhập bằng break-glass account → xác nhận KHÔNG bị yêu cầu MFA
Cách 2 — Microsoft Graph PowerShell
Microsoft Graph PowerShell
# Bật policy từ Report-only sang On
$policyId = (Get-MgIdentityConditionalAccessPolicy `
  -Filter "displayName eq 'CA-AZ500-RequireMFA-PrivilegedAdmins'").Id

Update-MgIdentityConditionalAccessPolicy `
  -ConditionalAccessPolicyId $policyId `
  -State "enabled"    # "enabled" = On | "disabled" = Off | "enabledForReportingButNotEnforced" = Report-only

Write-Host "Policy state updated to: enabled (On)"

# Xác nhận trạng thái
Get-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId $policyId |
  Select-Object DisplayName, State
Kết quả bước 4: Policy State = On. Admin user bị yêu cầu hoàn thành MFA khi đăng nhập portal. Break-glass không bị chặn. Sign-in log ghi nhận CA policy applied = Success.

📊 Kết Quả Đầu Ra

Group tạo thành công

GRP-AZ500-PrivilegedAdmins có admin01, hiển thị trong Entra ID Groups

CA Policy State = On

Policy CA-AZ500-RequireMFA-PrivilegedAdmins trạng thái Enabled

Admin bị yêu cầu MFA

Sign-in log: Conditional Access = Success, MFA được enforce

Break-glass không bị chặn

az500-breakglass đăng nhập thành công không cần MFA nhờ Exclude

What If xác nhận đúng

What If cho admin01 + Azure Management → policy matched, Grant = MFA

Report-only log ghi nhận

Trước khi bật On, sign-in log hiển thị policy would have applied

🧹 Dọn Dẹp

Giữ lại policy nếu muốn dùng cho các lab tiếp theo. Nếu cần tắt để tránh ảnh hưởng lab khác:

Azure CLI / PowerShell
# Tắt policy (không xóa — giữ lại để tham khảo)
# PowerShell:
Update-MgIdentityConditionalAccessPolicy `
  -ConditionalAccessPolicyId $policyId `
  -State "disabled"

# Hoặc Portal: Conditional Access → policy → Enable policy → Off → Save

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

1. Report-only mode khác gì với mode Off và On trong Conditional Access?

Gợi ý: Report-only ghi log như thể policy đang chạy nhưng không enforce thật — giúp đánh giá tác động trước khi bật thật

2. Tại sao break-glass account phải được loại trừ khỏi tất cả Conditional Access policies?

Gợi ý: Dùng khi tenant bị khóa, MFA hỏng hoặc admin không đăng nhập được — break-glass là tài khoản khẩn cấp cuối cùng

3. What If tool trong Conditional Access dùng để làm gì?

Gợi ý: Mô phỏng kết quả CA policy sẽ áp dụng cho một user + app + điều kiện cụ thể mà không cần đăng nhập thật

4. Khi tạo CA policy yêu cầu MFA cho admin, nên target resource là gì để bao gồm Azure Portal?

Gợi ý: Microsoft Azure Management (App ID: 797f4846-ba00-4fd7-ba43-dac1f8f63013) hoặc chọn All cloud apps

5. Sau khi bật policy On, admin chưa đăng ký MFA thì điều gì xảy ra?

Gợi ý: Admin sẽ bị redirect đến trang đăng ký MFA (Combined Security Registration) trước khi được cấp quyền truy cập

Lab 04: Administrative Unit Thư viện Labs Lab 06: Authentication Methods
Zalo