Azure 原則 提供簡單的方法,可使用 Azure 監視器的 診斷設定 來啟用大規模記錄。 本文說明如何使用一組內建原則,將 支援資源 的資源記錄導向至 Log Analytics 工作區、事件中樞和儲存體帳戶。 若要為沒有內建原則的資源類型建立自訂原則定義,請參閱使用 Azure 原則和計劃大規模建立診斷設定。
政策和舉措
計劃是政策的集合。 您可以指派一個包含所需不同原則的單一方案,而不是將多個原則指派給一個範圍。 您稍後可以將政策新增至此專案,而不變更指派。
一組內建方案可協助您套用不同目的地的診斷設定。 對於 allLogs 和 audit 類別群組,每種目的地類型都有一個唯一的方案。 每個方案都包含支援資源的所有整組內建原則。
新增作業
使用下列其中一種方法,部署診斷設定的內建計劃或原則。
使用下列步驟,使用 Azure 入口網站套用計劃或原則。
從 Azure 入口網站的 [原則] 頁面,選取 [ 定義]。
設定下列篩選器:
- 對於 [類別],選取 [監視]。
- 針對 [定義類型],選取 [計劃 ] 或 [原則]。
找出並選取您想要指派的方案或原則。
從定義頁面中,選取指派任務。
設定指派的 範圍 。 範圍可以是管理群組、訂用帳戶或資源群組。 計劃或原則會套用至範圍內的所有資源。
選取 參數 索引標籤,然後選取您要傳送記錄的特定目的地。 這些詳細資訊會因目的地類型而異。 請參閱 引數, 以取得每個目的地型別引數的詳細資訊。
選取 [修復 ] 索引標籤。這會將原則套用至範圍中的現有資源。 如果沒有補救工作,方案或原則指派只會套用至指派後所建立的新資源。
啟用 [ 建立補救工作 ] 複選框,然後確定已啟用 [建立受控識別 ]。 在 [受控識別類型] 下,選取 [系統指派的受控識別]。
選取 [檢閱 + 建立],然後選取 [建立]。
補救工作
原則會在建立時套用至新資源。 使用補救任務將原則套用至現有資源。 對於倡議,您必須為倡議中的每項策略建立整改任務。 上述每個程序都包含在指派方案或原則時建立補救工作的步驟。 您也可以在建立指派後建立補救工作。
在 Azure 入口網站中,選取 [ 補救] ,然後選取您的原則。 按一下 修復。 如需補救工作的詳細資訊,請參閱 補救不合規的資源。
選取 [ 修復 ],然後在 [原則修復] 頁面的 [ 修復工作 ] 索引標籤中追蹤修復工作的狀態。
參數
常見參數
下表說明建立診斷設定之每組原則和計劃的通用參數。
| 參數 | 說明 | 有效的值 | 預設 |
|---|---|---|---|
| 效果 | 啟用或停用原則的執行 | DeployIfNotExists、 AuditIfNotExists、 已停用 |
DeployIfNotExists |
| 診斷設定名稱 | 診斷設定名稱 | setByPolicy-{LogAnalytics|EventHubs|Storage} | |
| categoryGroup | 診斷類別群組 | 無、 稽核、 allLogs |
稽核 |
| 資源類型列表 | 對於計劃,要評估診斷設定是否存在的資源類型清單。 | 支援的資源 | 所有支援的資源 |
Log Analytics 參數
下表說明使用 Log Analytics 做為目的地的每組原則和計劃的參數。
| 參數 | 說明 | 有效的值 | 預設 |
|---|---|---|---|
| resourceLocationList | 將記錄傳送至鄰近 Log Analytics 的資源位置清單。 "*" 選取所有位置 |
支援的位置 | * |
| logAnalytics | Log Analytics 工作區 |
事件中樞參數
下表說明使用事件中樞作為目的地的每組原則和計劃的參數。
| 參數 | 說明 | 有效的值 | 預設 |
|---|---|---|---|
| resourceLocation | 資源位置必須與事件中樞命名空間位於相同的位置 | 支援的位置 | |
| eventHubAuthorizationRuleId | 事件中樞授權規則識別碼。 授權規則位於事件中樞命名空間層級。 例如,/subscriptions/{subscription ID}/resourceGroups/{resource group}/providers/Microsoft.EventHub/namespaces/{Event Hub namespace}/authorizationrules/{authorization rule} | ||
| eventHubName | 事件中樞名稱 | 監測 |
儲存體帳戶原則參數
下表說明使用儲存體帳戶作為目的地的每組原則和計劃的參數。
| 參數 | 說明 | 有效的值 | 預設 |
|---|---|---|---|
| resourceLocation | 資源位置必須與儲存體帳戶位於相同位置 | 支援的位置 | |
| storageAccount | 儲存體帳戶資源識別碼 |
支援的資源
下列資源有 Log Analytics 工作區、事件中樞和儲存體帳戶的內建所有記錄和稽核記錄原則:
| 資源類型 | 所有記錄 | 稽核記錄 |
|---|---|---|
| microsoft.aad/domainservices | 是的 | 是的 |
| microsoft.agfoodplatform/farmbeats(微軟農業食品平台) | 是的 | 是的 |
| microsoft.analysisservices/servers | 是的 | 否 |
| microsoft.apimanagement/service | 是的 | 是的 |
| microsoft.app/managedenvironments | 是的 | 是的 |
| microsoft.appconfiguration/configurationstores | 是的 | 是的 |
| microsoft.appplatform/spring | 是的 | 否 |
| microsoft.attestation/attestationproviders | 是的 | 是的 |
| microsoft.automation/automationaccounts | 是的 | 是的 |
| microsoft.autonomousdevelopmentplatform/workspaces | 是的 | 否 |
| microsoft.avs/privateclouds | 是的 | 是的 |
| microsoft.azureplaywrightservice/accounts | 是的 | 是的 |
| microsoft.azuresphere/catalogs | 是的 | 是的 |
| microsoft.batch/batchaccounts | 是的 | 是的 |
| microsoft.botservice/botservices | 是的 | 否 |
| microsoft.cache/redis (微軟緩存/Redis) | 是的 | 是的 |
| microsoft.cache/redisenterprise/databases | 是的 | 是的 |
| microsoft.cdn/cdnwebapplicationfirewallpolicies | 是的 | 否 |
| microsoft.cdn/profiles | 是的 | 是的 |
| microsoft.cdn/profiles/endpoints | 是的 | 否 |
| microsoft.chaos/experiments | 是的 | 是的 |
| microsoft.classicnetwork/networksecuritygroups | 是的 | 否 |
| microsoft.cloudtest/hostedpools | 是的 | 否 |
| microsoft.codeigning/codeigningaccounts | 是的 | 是的 |
| 微軟.認知服務/帳戶 | 是的 | 是的 |
| 微軟.通信/通信服務 | 是的 | 否 |
| microsoft.community/communitytrainings | 是的 | 是的 |
| microsoft.confidentialledger/managedccfs | 是的 | 是的 |
| microsoft.connectedcache/enterprisemcccustomers | 是的 | 否 |
| microsoft.connectedcache/ispcustomers | 是的 | 否 |
| microsoft.containerinstance/containergroups | 是的 | 否 |
| microsoft.containerregistry/registries | 是的 | 是的 |
| microsoft.customproviders/resourceproviders | 是的 | 否 |
| microsoft.d365客戶洞察/實例 | 是的 | 否 |
| microsoft.dashboard/grafana | 是的 | 是的 |
| microsoft.databricks/workspaces | 是的 | 否 |
| microsoft.datafactory/factories | 是的 | 否 |
| Microsoft Data Lake Analytics 帳戶(microsoft.datalakeanalytics/accounts) | 是的 | 否 |
| microsoft.datalakestore/accounts | 是的 | 否 |
| microsoft.dataprotection/backupvaults | 是的 | 否 |
| microsoft.datashare/accounts | 是的 | 否 |
| microsoft.dbformariadb/servers | 是的 | 否 |
| microsoft.dbformysql/flexibleservers | 是的 | 是的 |
| microsoft.dbformysql/servers | 是的 | 否 |
| microsoft.dbforpostgresql/flexibleservers | 是的 | 是的 |
| microsoft.dbforpostgresql/servergroupsv2 | 是的 | 否 |
| microsoft.dbforpostgresql/servers | 是的 | 否 |
| Microsoft 桌面虛擬化/應用程式群組 | 是的 | 否 |
| 微軟桌面虛擬化/主機池 | 是的 | 否 |
| microsoft.desktopvirtualization/scalingplans | 是的 | 否 |
| 微軟.桌面虛擬化/工作區 | 是的 | 否 |
| microsoft.devcenter/devcenters (微軟開發者中心) | 是的 | 是的 |
| microsoft.devices/iothubs | 是的 | 是的 |
| microsoft.devices/provisioningservices | 是的 | 否 |
| microsoft.digitaltwins/數位孿生實例 | 是的 | 否 |
| microsoft.documentdb/cassandraclusters | 是的 | 是的 |
| microsoft.documentdb/databaseaccounts | 是的 | 是的 |
| microsoft.documentdb/mongoclusters | 是的 | 是的 |
| microsoft.eventgrid/domains | 是的 | 是的 |
| microsoft.eventgrid/合作夥伴命名空間 | 是的 | 是的 |
| 微軟事件網格/合作伙伴主題 | 是的 | 否 |
| microsoft.eventgrid/systemtopics | 是的 | 否 |
| microsoft.eventgrid/topics | 是的 | 是的 |
| microsoft.eventhub/namespaces | 是的 | 是的 |
| microsoft.experimentation/experimentworkspaces | 是的 | 否 |
| microsoft.healthcareapis/services | 是的 | 否 |
| microsoft.healthcareapis/workspaces/dicomservices | 是的 | 否 |
| microsoft.healthcareapis/workspaces/fhirservices | 是的 | 否 |
| microsoft.healthcareapis/workspaces/iotconnectors | 是的 | 否 |
| microsoft.insights/autoscalesettings | 是的 | 否 |
| microsoft.insights/components | 是的 | 否 |
| Microsoft.insights/資料收集規則 | 是的 | 否 |
| microsoft.keyvault/managedhsms | 是的 | 是的 |
| microsoft.keyvault/vaults | 是的 | 是的 |
| microsoft.kusto/clusters | 是的 | 是的 |
| 微軟.負載測試服務/負載測試 | 是的 | 是的 |
| microsoft.logic/integrationaccounts | 是的 | 否 |
| microsoft.logic/workflows | 是的 | 否 |
| 微軟.機器學習服務/註冊表 | 是的 | 是的 |
| microsoft.machinelearningservices/workspaces(微軟機器學習服務/工作區) | 是的 | 是的 |
| microsoft.machinelearningservices/workspaces/onlineendpoints | 是的 | 否 |
| microsoft.managednetworkfabric/networkdevices | 是的 | 否 |
| microsoft.media/mediaservices | 是的 | 是的 |
| microsoft.media/mediaservices/liveevents | 是的 | 是的 |
| microsoft.media/mediaservices/streamingendpoints | 是的 | 是的 |
| microsoft.netapp/netappaccounts/capacitypools/volumes | 是的 | 是的 |
| microsoft.network/applicationgateways | 是的 | 否 |
| microsoft.network/azurefirewalls | 是的 | 否 |
| microsoft.network/bastionhosts | 是的 | 是的 |
| microsoft.network/dnsresolverpolicies | 是的 | 否 |
| microsoft.network/expressroutecircuits | 是的 | 否 |
| microsoft.network/frontdoors | 是的 | 是的 |
| microsoft.network/loadbalancers | 是的 | 否 |
| microsoft.network/networkmanagers(微軟網路管理者) | 是的 | 是的 |
| microsoft.network/networkmanagers/ipampools | 是的 | 是的 |
| microsoft.network/網路安全群組 (networksecuritygroups) | 是的 | 否 |
| microsoft.network/網路安全邊界 | 是的 | 否 |
| microsoft.network/p2svpngateways | 是的 | 是的 |
| microsoft.network/publicipaddresses (公共 IP 位址) | 是的 | 是的 |
| microsoft.network/publicipprefixes | 是的 | 是的 |
| microsoft.network/trafficmanagerprofiles | 是的 | 否 |
| microsoft.network/virtualnetworkgateways | 是的 | 是的 |
| microsoft.network/virtualnetworks | 是的 | 否 |
| microsoft.network/vpngateways | 是的 | 否 |
| microsoft.networkanalytics/dataproducts | 是的 | 是的 |
| microsoft.networkcloud/baremetalmachines | 是的 | 否 |
| microsoft.networkcloud/clusters | 是的 | 否 |
| 微軟網絡雲/存儲設備 | 是的 | 否 |
| 微軟.網路功能/Azure流量收集器 | 是的 | 否 |
| microsoft.notificationhubs/namespaces | 是的 | 是的 |
| microsoft.notificationhubs/namespaces/notificationhubs | 是的 | 是的 |
| microsoft.openenergyplatform/energyservices (微軟能源平台/能源服務) | 是的 | 否 |
| microsoft.operationalinsights/workspaces | 是的 | 是的 |
| microsoft.powerbi/tenants/workspaces | 是的 | 否 |
| microsoft.powerbidedicated/capacities | 是的 | 否 |
| 微軟.Purview/帳戶 | 是的 | 是的 |
| microsoft.recoveryservices/vaults | 是的 | 否 |
| microsoft.relay/namespaces | 是的 | 否 |
| microsoft.search/searchservices | 是的 | 是的 |
| microsoft.servicebus/命名空間 | 是的 | 是的 |
| microsoft.servicenetworking/trafficcontrollers | 是的 | 否 |
| microsoft.signalrservice/signalr | 是的 | 是的 |
| Microsoft SignalR 服務/WebPubSub | 是的 | 是的 |
| microsoft.sql/managedinstances | 是的 | 是的 |
| microsoft.sql/managedinstances/databases | 是的 | 否 |
| microsoft.sql/伺服器/資料庫 | 是的 | 是的 |
| microsoft.storagecache/caches | 是的 | 否 |
| microsoft.storagemover/storagemovers | 是的 | 否 |
| microsoft.streamanalytics/streamingjobs | 是的 | 否 |
| microsoft.synapse/workspaces | 是的 | 是的 |
| microsoft.synapse/workspaces/bigdatapools | 是的 | 是的 |
| microsoft.synapse/workspaces/kustopools | 是的 | 是的 |
| microsoft.synapse/workspaces/scopepools | 是的 | 是的 |
| microsoft.synapse/workspaces/sqlpools | 是的 | 是的 |
| microsoft.timeseriesinsights/environments | 是的 | 否 |
| microsoft.timeseriesinsights/environments/eventsources | 是的 | 否 |
| microsoft.videoindexer/accounts (影片索引器帳戶) | 是的 | 否 |
| microsoft.web/hostingenvironments | 是的 | 是的 |
| microsoft.workloads/sapvirtualinstances | 是的 | 是的 |






