Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Policy provides a simple method to enable logging at-scale with diagnostic settings for Azure Monitor. This article describes how to use a set of built-in policies to direct resource logs for supported resources to Log Analytics Workspaces, Event Hubs, and Storage Accounts. To create a custom policy definition for a resource type that doesn't have a built-in policy, see Create diagnostic settings at scale using Azure Policies and Initiatives.
Policies and initiatives
An initiative is a collection of policies. Rather than assigning multiple policies to a scope, you can assign a single initiative that includes the different policies you need. You can later add policies to this initiative without changing the assignment.
A set of built-in initiatives are available to help you apply diagnostic settings for different destinations. There is a unique initiative for each destination type for the allLogs
and audit
category groups. Each initiative contains all the entire set of built-in policies for the supported resources.
Create assignment
Deploy a built-in initiative or policy for diagnostic settings using one of the following methods.
Use the following steps to apply an initiative or policy using the Azure portal.
From the Policy page in the Azure portal, select Definitions.
Set the following filter:
- For the Category, select Monitoring.
- For the Definition type, select Initiative or Policy.
Locate and select the initiative or policy you want to assign.
For initiatives, type audit or allLogs in the Search field and then select the initiative for your destination.
For policies, type the name of your resource type in the Search field and then select the policy for your resource type and destination. The sample below sends key vault data to a Log Analytics workspace.
From the definition page, select Assign initiative.
Set a Scope for the assignment. The scope can be a management group, subscription, or resource group. The initiative or policy is applied to all resources within the scope.
Select the Parameters tab and then select the specific destination where you want to send the logs. These details will vary for each destination type. See Parameters for more information on the parameters for each destination type.
Select the Remediation tab. This will apply the policy to existing resources in the scope. Without a remediation task, the initiative or policy assignment only applies to new resources created after the assignment.
Enable the Create a remediation task checkbox and then ensure that Create a Managed Identity is enabled. Under Type of Managed Identity, select System assigned Managed Identity.
Select Review + create, then select Create .
Remediation tasks
Policies are applied to new resources when they're created. Use a remediation task to apply the policy to existing resources. For an initiative, you must create a remediation task for each policy in the initiative. Each of the processes above includes the steps to create a remediation task when you assign the initiative or policy. You can also create a remediation task after the assignment is created.
In the Azure portal, select Remediation and then select your policy. Click Remediate. For more information on remediation tasks, see Remediate noncompliant resources.
Select Remediate and then track the status of your remediation task in the Remediation tasks tab of the Policy Remediation page.
Parameters
Common parameters
The following table describes the common parameters for each set of policies and initiatives that create diagnostic settings.
Parameter | Description | Valid Values | Default |
---|---|---|---|
effect | Enable or disable the execution of the policy | DeployIfNotExists, AuditIfNotExists, Disabled |
DeployIfNotExists |
diagnosticSettingName | Diagnostic Setting Name | setByPolicy-{LogAnalytics|EventHubs|Storage} | |
categoryGroup | Diagnostic category group | none, audit, allLogs |
audit |
resourceTypeList | For initiatives, a list of resource types to be evaluated for diagnostic setting existence. | Supported resources | All supported resources |
Log Analytics parameters
The following table describes the parameters for each set of policies and initiatives that use Log Analytics as a destination.
Parameter | Description | Valid Values | Default |
---|---|---|---|
resourceLocationList | Resource Location List to send logs to nearby Log Analytics. "*" selects all locations |
Supported locations | * |
logAnalytics | Log Analytics Workspace |
Event Hubs parameters
The following table describes the parameters for each set of policies and initiatives that use event hubs as a destination.
Parameter | Description | Valid Values | Default |
---|---|---|---|
resourceLocation | Resource Location must be the same location as the event hub Namespace | Supported locations | |
eventHubAuthorizationRuleId | Event hub Authorization Rule ID. The authorization rule is at event hub namespace level. For example, /subscriptions/{subscription ID}/resourceGroups/{resource group}/providers/Microsoft.EventHub/namespaces/{Event Hub namespace}/authorizationrules/{authorization rule} | ||
eventHubName | Event hub name | Monitoring |
Storage Accounts policy parameters
The following table describes the parameters for each set of policies and initiatives that use storage accounts as a destination.
Parameter | Description | Valid Values | Default |
---|---|---|---|
resourceLocation | Resource Location must be in the same location as the Storage Account | Supported locations | |
storageAccount | Storage Account resourceId |
Supported resources
Built-in All logs and Audit logs policies for Log Analytics workspaces, Event Hubs, and Storage Accounts exist for the following resources:
Resource Type | All logs | Audit Logs |
---|---|---|
microsoft.aad/domainservices | Yes | Yes |
microsoft.agfoodplatform/farmbeats | Yes | Yes |
microsoft.analysisservices/servers | Yes | No |
microsoft.apimanagement/service | Yes | Yes |
microsoft.app/managedenvironments | Yes | Yes |
microsoft.appconfiguration/configurationstores | Yes | Yes |
microsoft.appplatform/spring | Yes | No |
microsoft.attestation/attestationproviders | Yes | Yes |
microsoft.automation/automationaccounts | Yes | Yes |
microsoft.autonomousdevelopmentplatform/workspaces | Yes | No |
microsoft.avs/privateclouds | Yes | Yes |
microsoft.azureplaywrightservice/accounts | Yes | Yes |
microsoft.azuresphere/catalogs | Yes | Yes |
microsoft.batch/batchaccounts | Yes | Yes |
microsoft.botservice/botservices | Yes | No |
microsoft.cache/redis | Yes | Yes |
microsoft.cache/redisenterprise/databases | Yes | Yes |
microsoft.cdn/cdnwebapplicationfirewallpolicies | Yes | No |
microsoft.cdn/profiles | Yes | Yes |
microsoft.cdn/profiles/endpoints | Yes | No |
microsoft.chaos/experiments | Yes | Yes |
microsoft.classicnetwork/networksecuritygroups | Yes | No |
microsoft.cloudtest/hostedpools | Yes | No |
microsoft.codesigning/codesigningaccounts | Yes | Yes |
microsoft.cognitiveservices/accounts | Yes | Yes |
microsoft.communication/communicationservices | Yes | No |
microsoft.community/communitytrainings | Yes | Yes |
microsoft.confidentialledger/managedccfs | Yes | Yes |
microsoft.connectedcache/enterprisemcccustomers | Yes | No |
microsoft.connectedcache/ispcustomers | Yes | No |
microsoft.containerinstance/containergroups | Yes | No |
microsoft.containerregistry/registries | Yes | Yes |
microsoft.customproviders/resourceproviders | Yes | No |
microsoft.d365customerinsights/instances | Yes | No |
microsoft.dashboard/grafana | Yes | Yes |
microsoft.databricks/workspaces | Yes | No |
microsoft.datafactory/factories | Yes | No |
microsoft.datalakeanalytics/accounts | Yes | No |
microsoft.datalakestore/accounts | Yes | No |
microsoft.dataprotection/backupvaults | Yes | No |
microsoft.datashare/accounts | Yes | No |
microsoft.dbformariadb/servers | Yes | No |
microsoft.dbformysql/flexibleservers | Yes | Yes |
microsoft.dbformysql/servers | Yes | No |
microsoft.dbforpostgresql/flexibleservers | Yes | Yes |
microsoft.dbforpostgresql/servergroupsv2 | Yes | No |
microsoft.dbforpostgresql/servers | Yes | No |
microsoft.desktopvirtualization/applicationgroups | Yes | No |
microsoft.desktopvirtualization/hostpools | Yes | No |
microsoft.desktopvirtualization/scalingplans | Yes | No |
microsoft.desktopvirtualization/workspaces | Yes | No |
microsoft.devcenter/devcenters | Yes | Yes |
microsoft.devices/iothubs | Yes | Yes |
microsoft.devices/provisioningservices | Yes | No |
microsoft.digitaltwins/digitaltwinsinstances | Yes | No |
microsoft.documentdb/cassandraclusters | Yes | Yes |
microsoft.documentdb/databaseaccounts | Yes | Yes |
microsoft.documentdb/mongoclusters | Yes | Yes |
microsoft.eventgrid/domains | Yes | Yes |
microsoft.eventgrid/partnernamespaces | Yes | Yes |
microsoft.eventgrid/partnertopics | Yes | No |
microsoft.eventgrid/systemtopics | Yes | No |
microsoft.eventgrid/topics | Yes | Yes |
microsoft.eventhub/namespaces | Yes | Yes |
microsoft.experimentation/experimentworkspaces | Yes | No |
microsoft.healthcareapis/services | Yes | No |
microsoft.healthcareapis/workspaces/dicomservices | Yes | No |
microsoft.healthcareapis/workspaces/fhirservices | Yes | No |
microsoft.healthcareapis/workspaces/iotconnectors | Yes | No |
microsoft.insights/autoscalesettings | Yes | No |
microsoft.insights/components | Yes | No |
microsoft.insights/datacollectionrules | Yes | No |
microsoft.keyvault/managedhsms | Yes | Yes |
microsoft.keyvault/vaults | Yes | Yes |
microsoft.kusto/clusters | Yes | Yes |
microsoft.loadtestservice/loadtests | Yes | Yes |
microsoft.logic/integrationaccounts | Yes | No |
microsoft.logic/workflows | Yes | No |
microsoft.machinelearningservices/registries | Yes | Yes |
microsoft.machinelearningservices/workspaces | Yes | Yes |
microsoft.machinelearningservices/workspaces/onlineendpoints | Yes | No |
microsoft.managednetworkfabric/networkdevices | Yes | No |
microsoft.media/mediaservices | Yes | Yes |
microsoft.media/mediaservices/liveevents | Yes | Yes |
microsoft.media/mediaservices/streamingendpoints | Yes | Yes |
microsoft.netapp/netappaccounts/capacitypools/volumes | Yes | Yes |
microsoft.network/applicationgateways | Yes | No |
microsoft.network/azurefirewalls | Yes | No |
microsoft.network/bastionhosts | Yes | Yes |
microsoft.network/dnsresolverpolicies | Yes | No |
microsoft.network/expressroutecircuits | Yes | No |
microsoft.network/frontdoors | Yes | Yes |
microsoft.network/loadbalancers | Yes | No |
microsoft.network/networkmanagers | Yes | Yes |
microsoft.network/networkmanagers/ipampools | Yes | Yes |
microsoft.network/networksecuritygroups | Yes | No |
microsoft.network/networksecurityperimeters | Yes | No |
microsoft.network/p2svpngateways | Yes | Yes |
microsoft.network/publicipaddresses | Yes | Yes |
microsoft.network/publicipprefixes | Yes | Yes |
microsoft.network/trafficmanagerprofiles | Yes | No |
microsoft.network/virtualnetworkgateways | Yes | Yes |
microsoft.network/virtualnetworks | Yes | No |
microsoft.network/vpngateways | Yes | No |
microsoft.networkanalytics/dataproducts | Yes | Yes |
microsoft.networkcloud/baremetalmachines | Yes | No |
microsoft.networkcloud/clusters | Yes | No |
microsoft.networkcloud/storageappliances | Yes | No |
microsoft.networkfunction/azuretrafficcollectors | Yes | No |
microsoft.notificationhubs/namespaces | Yes | Yes |
microsoft.notificationhubs/namespaces/notificationhubs | Yes | Yes |
microsoft.openenergyplatform/energyservices | Yes | No |
microsoft.operationalinsights/workspaces | Yes | Yes |
microsoft.powerbi/tenants/workspaces | Yes | No |
microsoft.powerbidedicated/capacities | Yes | No |
microsoft.purview/accounts | Yes | Yes |
microsoft.recoveryservices/vaults | Yes | No |
microsoft.relay/namespaces | Yes | No |
microsoft.search/searchservices | Yes | Yes |
microsoft.servicebus/namespaces | Yes | Yes |
microsoft.servicenetworking/trafficcontrollers | Yes | No |
microsoft.signalrservice/signalr | Yes | Yes |
microsoft.signalrservice/webpubsub | Yes | Yes |
microsoft.sql/managedinstances | Yes | Yes |
microsoft.sql/managedinstances/databases | Yes | No |
microsoft.sql/servers/databases | Yes | Yes |
microsoft.storagecache/caches | Yes | No |
microsoft.storagemover/storagemovers | Yes | No |
microsoft.streamanalytics/streamingjobs | Yes | No |
microsoft.synapse/workspaces | Yes | Yes |
microsoft.synapse/workspaces/bigdatapools | Yes | Yes |
microsoft.synapse/workspaces/kustopools | Yes | Yes |
microsoft.synapse/workspaces/scopepools | Yes | Yes |
microsoft.synapse/workspaces/sqlpools | Yes | Yes |
microsoft.timeseriesinsights/environments | Yes | No |
microsoft.timeseriesinsights/environments/eventsources | Yes | No |
microsoft.videoindexer/accounts | Yes | No |
microsoft.web/hostingenvironments | Yes | Yes |
microsoft.workloads/sapvirtualinstances | Yes | Yes |