Azure Local离线部署之Fallback日志收集

📅 2026/7/16 0:32:07 👁️ 阅读次数 📝 编程学习
Azure Local离线部署之Fallback日志收集

1. 适用场景

官方原文:"Use appliance fallback logging to collect and send logs to Microsoft when the Azure Local disconnected operations appliance virtual machine (VM) is down. Use this method if standard log collection can't start and you need logs to troubleshoot issues."

  • Appliance VM 起不来management endpoint 不工作
  • 标准 on-demand 收集无法启动

2. 前置

官方原文:"To use the cmdlets in this article, import the appliance logging module."

需导入 appliance logging module(PowerShell)。

⚠️ "Before you copy the module files to the target machine, run theUnblock-Filecmdlet on the files by using Windows PowerShell." ⚠️ "PowerShell ISE and PowerShell 7 aren't supported for log collection commands."

Import-Module "<disconnected operations module folder path>" -Force

3. 核心 cmdlet:Copy-DiagnosticData

官方原文:"TheCopy-DiagnosticDatacommand is used to copy diagnostic logs from mounted virtual hard disks (VHDs) to a specified folder."

作用:从已挂载的 VHD 拷贝诊断日志到指定文件夹。此 cmdlet 会关闭 Appliance VM

3.1 参数

参数必填说明
DiagnosticLogPath目标路径(包含日志副本 + 临时挂载的 VHD)
FilterRoles按 role 过滤(如 IRVM、EOS 等)
FromDate/ToDate时间窗;默认 = 当前时间前 4 小时
RecoveryKeySet(BitLocker)BitLocker 恢复密钥(protectorid + recoverypassword 对)

⚠️ 路径必须有足够空间——VHD 会临时挂载到该位置。

3.2 RecoveryKeySet 用法

部署后立即保存 BitLocker 恢复密钥(plan-security.md §3)。Fallback 时需要:

$certPasswordPlainText = "***" $certPassword = ConvertTo-SecureString $certPasswordPlainText -AsPlainText -Force $context = Set-DisconnectedOperationsClientContext ` -ManagementEndpointClientCertificatePath "<Management Endpoint Client Cert Path>" ` -ManagementEndpointClientCertificatePassword $certPassword ` -ManagementEndpointIpAddress "<Management Endpoint IP address>" $recoveryKeys = Get-ApplianceBitlockerRecoveryKeys $context $recoveryKeys.recoverykeyset | ConvertTo-JSON > c:\recoveryKeySet.json Get-Content c:\recoveryKeySet.json

输出形如:

[ { "protectorid": "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", "recoverypassword": "xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx" }, ... ]

3.3 构造 RecoveryKeySet 参数

protectorid+recoverypassword配对:

$recoveryKeySet = @( [PSCustomObject]@{ protectorid = "{Protec...}" recoverypassword = "xxxxxx-xxxxxx-..." }, ... )

4. 完整流程(推测 + 官方建议)

文档后续完整示例因抓取截断未完整显示,但工作流应如下:

  1. 在 Appliance VM down 的节点上:
    • Import-Module <ApplianceLoggingModule> -Force
    • 准备 RecoveryKeySet(如 §3.2)
  2. Copy-DiagnosticData -DiagnosticLogPath <path> -FilterRoles <roles> -FromDate <date> -ToDate <date> -RecoveryKeySet <keySet>
  3. cmdlet 自动挂载 VHD、关闭 appliance、解锁 BitLocker、拷贝日志到DiagnosticLogPath\LogsToExport
  4. LogsToExport拷出 → 通过支持流程给 Microsoft

5. "官方没明说"的事项

  • 文档没说"Copy-DiagnosticData 是否会自动把 VHD 卸载 + appliance 重启"——通常会,但建议手工验证
  • "PowerShell 7 不支持"——意味着必须用 Windows PowerShell 5.1(默认)
  • "FilterRoles" 没列出可选值列表——必须Get-Help Copy-DiagnosticData -Detailed
  • 文档没说"日志输出格式(zip/raw/structured)"
  • 文档没说"日志是否已经脱敏"——按推断 Microsoft 内部处理
  • "日志保留 30 天"是 on-demand 收集的策略;fallback 模式未明示保留周期(应该是你本地保存多久就多久)