Microsoft.Insights logprofiles

Bicep resource definition

The logprofiles 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/logprofiles resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Insights/logprofiles@2016-03-01' = {
  location: 'string'
  name: 'string'
  properties: {
    categories: [
      'string'
    ]
    locations: [
      'string'
    ]
    retentionPolicy: {
      days: int
      enabled: bool
    }
    serviceBusRuleId: 'string'
    storageAccountId: 'string'
  }
  tags: {
    {customized property}: 'string'
  }
}

Property Values

Microsoft.Insights/logprofiles

Name Description Value
location The geo-location where the resource lives string (required)
name The resource name string (required)
properties The log profile properties of the resource. LogProfileProperties (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates

LogProfileProperties

Name Description Value
categories the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' string[] (required)
locations List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. string[] (required)
retentionPolicy the retention policy for the events in the log. MicrosoftCommonRetentionPolicy (required)
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. 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 the Activity Log. string

MicrosoftCommonRetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int

Constraints:
Min value = 0 (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

TrackedResourceTags

Name Description Value

Usage Examples

Bicep Samples

A basic example of deploying Insights Log Profiles.

targetScope = 'subscription'

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource resourceGroup 'Microsoft.Resources/resourceGroups@2020-06-01' = {
  name: resourceName
  location: location
}

resource logProfile 'Microsoft.Insights/logProfiles@2016-03-01' = {
  name: resourceName
  properties: {
    categories: [
      'Action'
    ]
    locations: [
      'westeurope'
      'westeurope'
    ]
    retentionPolicy: {
      days: 7
      enabled: true
    }
    storageAccountId: module1.outputs.storageAccountId
  }
}

module module1 'main-rg-module.bicep' = {
  name: 'deploy-rg-resources'
  scope: resourceGroup
  params: {
    resourceName: resourceName
    location: location
  }
}

A basic example of deploying Insights Log Profiles.

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
  name: resourceName
  location: location
  sku: {
    name: 'Standard_GRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
    allowBlobPublicAccess: true
    allowCrossTenantReplication: true
    allowSharedKeyAccess: true
    defaultToOAuthAuthentication: false
    encryption: {
      keySource: 'Microsoft.Storage'
      services: {
        queue: {
          keyType: 'Service'
        }
        table: {
          keyType: 'Service'
        }
      }
    }
    isHnsEnabled: false
    isNfsV3Enabled: false
    isSftpEnabled: false
    minimumTlsVersion: 'TLS1_2'
    networkAcls: {
      defaultAction: 'Allow'
    }
    publicNetworkAccess: 'Enabled'
    supportsHttpsTrafficOnly: true
  }
}

// Module outputs for cross-scope references
output storageAccountId string = storageAccount.id

ARM template resource definition

The logprofiles 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/logprofiles resource, add the following JSON to your template.

{
  "type": "Microsoft.Insights/logprofiles",
  "apiVersion": "2016-03-01",
  "name": "string",
  "location": "string",
  "properties": {
    "categories": [ "string" ],
    "locations": [ "string" ],
    "retentionPolicy": {
      "days": "int",
      "enabled": "bool"
    },
    "serviceBusRuleId": "string",
    "storageAccountId": "string"
  },
  "tags": {
    "{customized property}": "string"
  }
}

Property Values

Microsoft.Insights/logprofiles

Name Description Value
apiVersion The api version '2016-03-01'
location The geo-location where the resource lives string (required)
name The resource name string (required)
properties The log profile properties of the resource. LogProfileProperties (required)
tags Resource tags Dictionary of tag names and values. See Tags in templates
type The resource type 'Microsoft.Insights/logprofiles'

LogProfileProperties

Name Description Value
categories the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' string[] (required)
locations List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. string[] (required)
retentionPolicy the retention policy for the events in the log. MicrosoftCommonRetentionPolicy (required)
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. 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 the Activity Log. string

MicrosoftCommonRetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int

Constraints:
Min value = 0 (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

TrackedResourceTags

Name Description Value

Usage Examples

Terraform (AzAPI provider) resource definition

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

  • Subscription

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

Resource format

To create a Microsoft.Insights/logprofiles resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Insights/logprofiles@2016-03-01"
  name = "string"
  parent_id = "string"
  location = "string"
  tags = {
    {customized property} = "string"
  }
  body = {
    properties = {
      categories = [
        "string"
      ]
      locations = [
        "string"
      ]
      retentionPolicy = {
        days = int
        enabled = bool
      }
      serviceBusRuleId = "string"
      storageAccountId = "string"
    }
  }
}

Property Values

Microsoft.Insights/logprofiles

Name Description Value
location The geo-location where the resource lives string (required)
name The resource name string (required)
properties The log profile properties of the resource. LogProfileProperties (required)
tags Resource tags Dictionary of tag names and values.
type The resource type "Microsoft.Insights/logprofiles@2016-03-01"

LogProfileProperties

Name Description Value
categories the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.' string[] (required)
locations List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. string[] (required)
retentionPolicy the retention policy for the events in the log. MicrosoftCommonRetentionPolicy (required)
serviceBusRuleId The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. 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 the Activity Log. string

MicrosoftCommonRetentionPolicy

Name Description Value
days the number of days for the retention in days. A value of 0 will retain the events indefinitely. int

Constraints:
Min value = 0 (required)
enabled a value indicating whether the retention policy is enabled. bool (required)

TrackedResourceTags

Name Description Value

Usage Examples

Terraform Samples

A basic example of deploying Insights Log Profiles.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
    azurerm = {
      source = "hashicorp/azurerm"
    }
  }
}

provider "azurerm" {
  features {
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

data "azurerm_client_config" "current" {
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "storageAccount" {
  type      = "Microsoft.Storage/storageAccounts@2021-09-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    kind = "StorageV2"
    properties = {
      accessTier                   = "Hot"
      allowBlobPublicAccess        = true
      allowCrossTenantReplication  = true
      allowSharedKeyAccess         = true
      defaultToOAuthAuthentication = false
      encryption = {
        keySource = "Microsoft.Storage"
        services = {
          queue = {
            keyType = "Service"
          }
          table = {
            keyType = "Service"
          }
        }
      }
      isHnsEnabled      = false
      isNfsV3Enabled    = false
      isSftpEnabled     = false
      minimumTlsVersion = "TLS1_2"
      networkAcls = {
        defaultAction = "Allow"
      }
      publicNetworkAccess      = "Enabled"
      supportsHttpsTrafficOnly = true
    }
    sku = {
      name = "Standard_GRS"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "logProfile" {
  type      = "Microsoft.Insights/logProfiles@2016-03-01"
  parent_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
  name      = var.resource_name
  location  = ""
  body = {
    properties = {
      categories = [
        "Action",
      ]
      locations = [
        "westeurope",
        "westeurope",
      ]
      retentionPolicy = {
        days    = 7
        enabled = true
      }
      storageAccountId = azapi_resource.storageAccount.id
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}