共用方式為


追蹤 Azure 防火牆規則集變更

本文說明如何使用 Azure Resource Graph 監視和追蹤 Azure 防火牆規則集合群組的變更。 變更追蹤可藉由提供規則集修改的詳細歷程記錄,協助您維護安全性合規性、稽核組態修改,以及疑難排解問題。

Azure Resource Graph 提供變更分析資料,可協助您追蹤何時在 Azure 防火牆規則集合群組上偵測到變更。 您可以跨訂用帳戶、管理群組或租用戶,大規模地檢視屬性變更詳細資料及查詢變更。

Azure 防火牆規則集合群組的變更追蹤可讓您:

  • 監控配置變更:追蹤防火牆規則和策略的所有修改
  • 保持合規性: 生成安全性和合規性要求的審計跟踪
  • 疑難排解問題:識別何時進行可能影響連線的變更
  • 分析趨勢: 了解規則修改隨時間變化的模式

先決條件

在追蹤規則集變更之前,請確認您符合下列需求:

  • 您有已設定規則集合群組的 Azure 防火牆
  • 您有適當的許可權來存取 Azure Resource Graph
  • 您的 Azure 防火牆使用 Azure 防火牆原則 (不是傳統規則)

進入 Azure Resource Graph 探索工具

若要執行變更追蹤查詢,您必須存取 Azure Resource Graph 瀏覽器。

  1. 登入 Azure 入口網站
  2. 搜尋並選取 Resource Graph Explorer
  3. 在查詢視窗中,您可以執行下列各節所述的變更追蹤查詢

基本變更追蹤查詢

使用此查詢來取得 Azure 防火牆規則集合群組所有變更的完整檢視:

networkresourcechanges
| where properties contains "microsoft.network/firewallpolicies/rulecollectiongroups"
| extend parsedProperties = parse_json(properties)
| extend TargetResource = tostring(parsedProperties.targetResourceId),
         Timestamp = todatetime(parsedProperties.changeAttributes.timestamp),
         Changes = todynamic(parsedProperties.changes),
         ChangeType = tostring(parsedProperties.changeType),
         PreviousSnapshotId = tostring(parsedProperties.changeAttributes.previousResourceSnapshotId),
         NewSnapshotId = tostring(parsedProperties.changeAttributes.newResourceSnapshotId),
         CorrelationId = tostring(parsedProperties.changeAttributes.correlationId),
         ChangesCount = toint(parsedProperties.changeAttributes.changesCount),
         TenantId = tostring(tenantId),
         Location = tostring(location),
         SubscriptionId = tostring(subscriptionId),
         ResourceGroup = tostring(resourceGroup),
         FirewallPolicyName = extract('/firewallPolicies/([^/]+)/', 1, tostring(id))
| mv-expand ChangeKey = bag_keys(Changes)
| extend ChangeDetails = todynamic(Changes[tostring(ChangeKey)])
| extend RuleCollectionName = extract('properties\\.ruleCollections\\["([^"]+)"\\]', 1, tostring(ChangeKey))
| where isnotempty(RuleCollectionName)
| summarize Changes = make_list(pack("ChangeKey", ChangeKey, "PreviousValue", tostring(ChangeDetails.previousValue), "NewValue", tostring(ChangeDetails.newValue)))
    by Timestamp = format_datetime(Timestamp, 'yyyy-MM-dd HH:mm:ss'),
       TenantId,
       SubscriptionId,
       ResourceGroup,
       Location,
       TargetResource,
       FirewallPolicyName,
       RuleCollectionName,
       ChangeType,
       PreviousSnapshotId,
       NewSnapshotId,
       CorrelationId,
       ChangesCount
| project Timestamp,
          TenantId,
          SubscriptionId,
          ResourceGroup,
          Location,
          TargetResource,
          FirewallPolicyName,
          RuleCollectionName,
          ChangeType,
          PreviousSnapshotId,
          NewSnapshotId,
          CorrelationId,
          ChangesCount,
          Changes
| order by Timestamp desc

瞭解查詢結果

變更追蹤查詢會針對每個偵測到的變更傳回下列資訊:

領域 Description
時間戳 變更發生的時間
SubscriptionId 包含防火牆的 Azure 訂用帳戶
資源群組 包含防火牆原則的資源群組
防火牆原則名稱 受影響防火牆原則的名稱
規則集合名稱 受影響規則集合的名稱
變更類型 變更類型 (建立、更新、刪除)
變更數量 變更的屬性數目
變更 變更內容的詳細清單,包括先前和新的值
CorrelationId 連結相關變更的唯一識別碼

依時段篩選變更

若要專注於最近的變更,您可以在查詢中新增時間篩選器:

networkresourcechanges
| where properties contains "microsoft.network/firewallpolicies/rulecollectiongroups"
| where todatetime(properties.changeAttributes.timestamp) >= ago(7d)  // Last 7 days
// ... rest of query

依特定防火牆原則篩選

若要追蹤特定防火牆原則的變更:

networkresourcechanges
| where properties contains "microsoft.network/firewallpolicies/rulecollectiongroups"
| where id contains "/firewallPolicies/your-policy-name"
// ... rest of query

設定自動監控

若要持續監控,請考慮設定:

  • 排程查詢:使用 Azure Logic Apps 或 Azure 自動化依排程執行查詢
  • 警示:根據變更模式建立 Azure 監視器警示
  • 報告:將結果匯出至儲存或視覺化工具以進行報告

最佳做法

在進行規則集變更追蹤時:

  • 定期監控:設定監控查詢執行程序,以便及時捕捉更改
  • 保留原則:規劃變更資料的長期儲存,以符合規範
  • 存取控制:根據安全性需求限制對變更追蹤資料的存取
  • 整合:考慮與現有的 SIEM 或監控工具整合

故障排除

如果搜尋結果沒有預期的變更:

  • 確認您使用的是 Azure 防火牆原則 (不是傳統規則)
  • 檢查查詢中的時段是否涵蓋變更發生的時間
  • 請確定您具有存取 Azure Resource Graph 的必要許可權
  • 確認篩選器中的資源名稱正確無誤