microsoft.insights diagnosticSettings 2015-07-01

Remarks

For guidance on deploying monitoring solutions, see Create monitoring resources by using Bicep.

Bicep resource definition

The diagnosticSettings resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a microsoft.insights/diagnosticSettings resource, add the following Bicep to your template.

resource symbolicname 'microsoft.insights/diagnosticSettings@2015-07-01' = {
  scope: resourceSymbolicName or scope
  location: 'string'
  name: 'service'
  properties: {
    logs: [
      {
        category: 'string'
        enabled: bool
        retentionPolicy: {
          days: int
          enabled: bool
        }
      }
    ]
    metrics: [
      {
        enabled: bool
        retentionPolicy: {
          days: int
          enabled: bool
        }
        timeGrain: 'string'
      }
    ]
    serviceBusRuleId: 'string'
    storageAccountId: 'string'
    workspaceId: 'string'
  }
  tags: {
    {customized property}: 'string'
  }
}

Property values

LogSettings

Name Description Value
category Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. string
enabled a value indicating whether this log is enabled. bool (required)
retentionPolicy the retention policy for this log. RetentionPolicy

MetricSettings

Name Description Value
enabled a value indicating whether this timegrain is enabled. bool (required)
retentionPolicy the retention policy for this timegrain. RetentionPolicy
timeGrain the timegrain of the metric in ISO8601 format. string (required)

microsoft.insights/diagnosticSettings

Name Description Value
location Resource location string (required)
name The resource name 'service' (required)
properties The diagnostic settings for service. ServiceDiagnosticSettings
scope Use when creating a resource at a scope that is different than the deployment scope. Set this property to the symbolic name of a resource to apply the extension resource.
tags Resource tags Dictionary of tag names and values. See Tags in templates

ResourceTags

Name Description Value

RetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

ServiceDiagnosticSettings

Name Description Value
logs the list of logs settings. LogSettings[]
metrics the list of metric settings. MetricSettings[]
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. string
storageAccountId The resource ID of the storage account to which you would like to send Diagnostic Logs. string
workspaceId The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 string

Quickstart samples

The following quickstart samples deploy this resource type.

Bicep File Description
AKS Cluster with a NAT Gateway and an Application Gateway This sample shows how to a deploy an AKS cluster with NAT Gateway for outbound connections and an Application Gateway for inbound connections.
AKS cluster with the Application Gateway Ingress Controller This sample shows how to deploy an AKS cluster with Application Gateway, Application Gateway Ingress Controller, Azure Container Registry, Log Analytics and Key Vault
Application Gateway with internal API Management and Web App Application Gateway routing Internet traffic to a virtual network (internal mode) API Management instance which services a web API hosted in an Azure Web App.
Application Gateway with WAF and firewall policy This template creates an Application Gateway with WAF configured along with a firewall policy
Azure Container Registry with Policies and Diagnostics Azure Container Registry with Policies and Diagnostics (bicep)
Azure Data Factory with Git and managed vnet configuration This template creates Azure Data Factory with Git configuration and managed virtual network.
Azure Game Developer Virtual Machine Azure Game Developer Virtual Machine includes Licencsed Engines like Unreal.
Azure SQL Server with Auditing written to Log Analytics This template allows you to deploy an Azure SQL server with Auditing enabled to write audit logs to Log Analytics (OMS workspace)
Create a Premium Redis Cache with clustering This template shows how to configure clustering in a premium Azure Redis Cache instance.
Create a Redis Cache using a template This template creates an Azure Redis Cache with diagnostics data kept in a storage account.
Create API Management in Internal VNet with App Gateway This template demonstrates how to Create a instance of Azure API Management on a private network protected by Azure Application Gateway.
Create Key Vault with logging enabled This template creates an Azure Key Vault and an Azure Storage account that is used for logging. It optionally creates resource locks to protect your Key Vault and storage resources.
Create Premium Redis Cache with data persistence This template shows how to configure persistence in a premium Azure Redis Cache instance.
Create Recovery Services Vault and Enable Diagnostics This template creates a Recovery Services Vault and enables diagnostics for Azure Backup. This also deploys storage account and oms workspace.
Create Recovery Services Vault with backup policies This template creates a Recovery Services Vault with backup policies and configure optional features such system identity, backup storage type, cross region restore and diagnostics logs and a delete lock.
Deploy a simple Azure Spring Apps microservice application This template deploys a simple Azure Spring Apps microservice application to run on Azure.
Deploy Secure Azure AI Studio with a managed virtual network This template creates a secure Azure AI Studio environment with robust network and identity security restrictions.
Front Door Premium with WAF and Microsoft-managed rule sets This template creates a Front Door Premium including a web application firewall with the Microsoft-managed default and bot protection rule sets.
Front Door Standard/Premium with WAF and custom rule This template creates a Front Door Standard/Premium including a web application firewall with a custom rule.
FrontDoor CDN with WAF, Domains and Logs to EventHub This template creates a new Azure FrontDoor cdn profile. Create WAF with custom and managed rules, cdn routes, origin and groups with their association with WAF and routes, configures custom domains, create event hub and diagnostic settings for sending CDN access logs using event hub.
Log Analytics workspace with solutions and data sources Deploys a Log Analytics workspace with specified solutions and data sources
Log Analytics workspace with VM Insights, Container Insights Deploys a Log Analytics workspace with VM Insights, Container Insights solutions and diagnostics.
Network Security Group with diagnostic logs This template creates a Network Security Group with diagnostic logs and a resource lock
Use Azure Firewall as a DNS Proxy in a Hub & Spoke topology This sample show how to deploy a hub-spoke topology in Azure using the Azure Firewall. The hub virtual network acts as a central point of connectivity to many spoke virtual networks that are connected to hub virtual network via virtual network peering.
Virtual Network with diagnostic logs This template creates a Virtual Network with diagnostic logs and allows optional features to be added to each subnet

ARM template resource definition

The diagnosticSettings resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a microsoft.insights/diagnosticSettings resource, add the following JSON to your template.

{
  "type": "microsoft.insights/diagnosticSettings",
  "apiVersion": "2015-07-01",
  "name": "string",
  "location": "string",
  "properties": {
    "logs": [
      {
        "category": "string",
        "enabled": "bool",
        "retentionPolicy": {
          "days": "int",
          "enabled": "bool"
        }
      }
    ],
    "metrics": [
      {
        "enabled": "bool",
        "retentionPolicy": {
          "days": "int",
          "enabled": "bool"
        },
        "timeGrain": "string"
      }
    ],
    "serviceBusRuleId": "string",
    "storageAccountId": "string",
    "workspaceId": "string"
  },
  "tags": {
    "{customized property}": "string"
  }
}

Property values

LogSettings

Name Description Value
category Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. string
enabled a value indicating whether this log is enabled. bool (required)
retentionPolicy the retention policy for this log. RetentionPolicy

MetricSettings

Name Description Value
enabled a value indicating whether this timegrain is enabled. bool (required)
retentionPolicy the retention policy for this timegrain. RetentionPolicy
timeGrain the timegrain of the metric in ISO8601 format. string (required)

microsoft.insights/diagnosticSettings

Name Description Value
apiVersion The api version '2015-07-01'
location Resource location string (required)
name The resource name 'service' (required)
properties The diagnostic settings for service. ServiceDiagnosticSettings
tags Resource tags Dictionary of tag names and values. See Tags in templates
type The resource type 'microsoft.insights/diagnosticSettings'

ResourceTags

Name Description Value

RetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

ServiceDiagnosticSettings

Name Description Value
logs the list of logs settings. LogSettings[]
metrics the list of metric settings. MetricSettings[]
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. string
storageAccountId The resource ID of the storage account to which you would like to send Diagnostic Logs. string
workspaceId The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 string

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
AKS Cluster with a NAT Gateway and an Application Gateway

Deploy to Azure
This sample shows how to a deploy an AKS cluster with NAT Gateway for outbound connections and an Application Gateway for inbound connections.
AKS cluster with the Application Gateway Ingress Controller

Deploy to Azure
This sample shows how to deploy an AKS cluster with Application Gateway, Application Gateway Ingress Controller, Azure Container Registry, Log Analytics and Key Vault
Application Gateway with internal API Management and Web App

Deploy to Azure
Application Gateway routing Internet traffic to a virtual network (internal mode) API Management instance which services a web API hosted in an Azure Web App.
Application Gateway with WAF and firewall policy

Deploy to Azure
This template creates an Application Gateway with WAF configured along with a firewall policy
Azure Container Registry with Policies and Diagnostics

Deploy to Azure
Azure Container Registry with Policies and Diagnostics (bicep)
Azure Data Factory with Git and managed vnet configuration

Deploy to Azure
This template creates Azure Data Factory with Git configuration and managed virtual network.
Azure Game Developer Virtual Machine

Deploy to Azure
Azure Game Developer Virtual Machine includes Licencsed Engines like Unreal.
Azure SQL Server with Auditing written to Log Analytics

Deploy to Azure
This template allows you to deploy an Azure SQL server with Auditing enabled to write audit logs to Log Analytics (OMS workspace)
Create a Premium Redis Cache with clustering

Deploy to Azure
This template shows how to configure clustering in a premium Azure Redis Cache instance.
Create a Redis Cache using a template

Deploy to Azure
This template creates an Azure Redis Cache with diagnostics data kept in a storage account.
Create API Management in Internal VNet with App Gateway

Deploy to Azure
This template demonstrates how to Create a instance of Azure API Management on a private network protected by Azure Application Gateway.
Create Key Vault with logging enabled

Deploy to Azure
This template creates an Azure Key Vault and an Azure Storage account that is used for logging. It optionally creates resource locks to protect your Key Vault and storage resources.
Create Premium Redis Cache with data persistence

Deploy to Azure
This template shows how to configure persistence in a premium Azure Redis Cache instance.
Create Recovery Services Vault and Enable Diagnostics

Deploy to Azure
This template creates a Recovery Services Vault and enables diagnostics for Azure Backup. This also deploys storage account and oms workspace.
Create Recovery Services Vault with backup policies

Deploy to Azure
This template creates a Recovery Services Vault with backup policies and configure optional features such system identity, backup storage type, cross region restore and diagnostics logs and a delete lock.
Create SQL MI with configured sending of logs and metrics

Deploy to Azure
This template allows you to deploy SQL MI and additional resources used for storing logs and metrics (diagnostic workspace, storage account, event hub).
Deploy a simple Azure Spring Apps microservice application

Deploy to Azure
This template deploys a simple Azure Spring Apps microservice application to run on Azure.
Deploy Secure Azure AI Studio with a managed virtual network

Deploy to Azure
This template creates a secure Azure AI Studio environment with robust network and identity security restrictions.
Front Door Premium with WAF and Microsoft-managed rule sets

Deploy to Azure
This template creates a Front Door Premium including a web application firewall with the Microsoft-managed default and bot protection rule sets.
Front Door Standard/Premium with WAF and custom rule

Deploy to Azure
This template creates a Front Door Standard/Premium including a web application firewall with a custom rule.
FrontDoor CDN with WAF, Domains and Logs to EventHub

Deploy to Azure
This template creates a new Azure FrontDoor cdn profile. Create WAF with custom and managed rules, cdn routes, origin and groups with their association with WAF and routes, configures custom domains, create event hub and diagnostic settings for sending CDN access logs using event hub.
Log Analytics workspace with solutions and data sources

Deploy to Azure
Deploys a Log Analytics workspace with specified solutions and data sources
Log Analytics workspace with VM Insights, Container Insights

Deploy to Azure
Deploys a Log Analytics workspace with VM Insights, Container Insights solutions and diagnostics.
Network Security Group with diagnostic logs

Deploy to Azure
This template creates a Network Security Group with diagnostic logs and a resource lock
Use Azure Firewall as a DNS Proxy in a Hub & Spoke topology

Deploy to Azure
This sample show how to deploy a hub-spoke topology in Azure using the Azure Firewall. The hub virtual network acts as a central point of connectivity to many spoke virtual networks that are connected to hub virtual network via virtual network peering.
Virtual Network with diagnostic logs

Deploy to Azure
This template creates a Virtual Network with diagnostic logs and allows optional features to be added to each subnet

Terraform (AzAPI provider) resource definition

The diagnosticSettings resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a microsoft.insights/diagnosticSettings resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "microsoft.insights/diagnosticSettings@2015-07-01"
  name = "string"
  parent_id = "string"
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = jsonencode({
    properties = {
      logs = [
        {
          category = "string"
          enabled = bool
          retentionPolicy = {
            days = int
            enabled = bool
          }
        }
      ]
      metrics = [
        {
          enabled = bool
          retentionPolicy = {
            days = int
            enabled = bool
          }
          timeGrain = "string"
        }
      ]
      serviceBusRuleId = "string"
      storageAccountId = "string"
      workspaceId = "string"
    }
  })
}

Property values

LogSettings

Name Description Value
category Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. string
enabled a value indicating whether this log is enabled. bool (required)
retentionPolicy the retention policy for this log. RetentionPolicy

MetricSettings

Name Description Value
enabled a value indicating whether this timegrain is enabled. bool (required)
retentionPolicy the retention policy for this timegrain. RetentionPolicy
timeGrain the timegrain of the metric in ISO8601 format. string (required)

microsoft.insights/diagnosticSettings

Name Description Value
location Resource location string (required)
name The resource name 'service' (required)
parent_id The ID of the resource to apply this extension resource to. string (required)
properties The diagnostic settings for service. ServiceDiagnosticSettings
tags Resource tags Dictionary of tag names and values.
type The resource type "microsoft.insights/diagnosticSettings@2015-07-01"

ResourceTags

Name Description Value

RetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

ServiceDiagnosticSettings

Name Description Value
logs the list of logs settings. LogSettings[]
metrics the list of metric settings. MetricSettings[]
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. string
storageAccountId The resource ID of the storage account to which you would like to send Diagnostic Logs. string
workspaceId The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 string