Azure Log Analytics Linked Service

This page shows how to write Terraform and Azure Resource Manager for Log Analytics Linked Service and write them securely.

azurerm_log_analytics_linked_service (Terraform)

The Linked Service in Log Analytics can be configured in Terraform with the resource name azurerm_log_analytics_linked_service. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

resource.log_analytics.tf#L10
resource "azurerm_log_analytics_linked_service" "automation" {
  provider            = azurerm.default
  resource_group_name = var.rg_name
  workspace_name      = azurerm_log_analytics_workspace.monitor.name
  resource_id         = var.automation_account_id
loganalytics.tf#L9
resource "azurerm_log_analytics_linked_service" "loganalyticslink" {
  resource_group_name = "hrwrg"
  workspace_name      = azurerm_log_analytics_workspace.loganalytics.name
  resource_id         = azurerm_automation_account.autoaccount.id
main.tf#L7
resource "azurerm_log_analytics_linked_service" "this" {
  linked_service_name = var.linked_service_name
  resource_group_name = var.resource_group_name
  resource_id         = var.resource_id
  tags                = var.tags
  workspace_name      = var.workspace_name
AutomationAccounts.tf#L18
resource "azurerm_log_analytics_linked_service" "AutomationAccount1_lawslink" {
  resource_group_name = azurerm_resource_group.monitoring.name
  workspace_id        = module.loganalytics.id
  read_access_id      = azurerm_automation_account.AutomationAccount1.id
}
aa-automation.tf#L26
resource "azurerm_log_analytics_linked_service" "law-link" {
  resource_group_name = azurerm_resource_group.tf-automation.name
  workspace_id        = azurerm_log_analytics_workspace.law-updates.id
  read_access_id      = azurerm_automation_account.aa-arc.id
main.tf#L7
resource "azurerm_log_analytics_linked_service" "this" {
  linked_service_name = var.linked_service_name
  resource_group_name = var.resource_group_name
  resource_id         = var.resource_id
  tags                = var.tags
  workspace_name      = var.workspace_name
automation.tf#L16
resource "azurerm_log_analytics_linked_service" "law_link" {
  resource_group_name = var.resource_group_name
  workspace_id        = var.law_id
  read_access_id      = azurerm_automation_account.aa.id
}

rg-monitor.tf#L56
resource "azurerm_log_analytics_linked_service" "la_monitor_log01_link_aut" {
  resource_group_name = azurerm_resource_group.rg_monitor.name
  workspace_id        = azurerm_log_analytics_workspace.la_monitor_log01.id
  read_access_id      = azurerm_automation_account.automation01.id
rg-monitor.tf#L56
resource "azurerm_log_analytics_linked_service" "la_monitor_log01_link_aut" {
  resource_group_name = azurerm_resource_group.rg_monitor.name
  workspace_id        = azurerm_log_analytics_workspace.la_monitor_log01.id
  read_access_id      = azurerm_automation_account.automation01.id
rg-monitor.tf#L56
resource "azurerm_log_analytics_linked_service" "la_monitor_log01_link_aut" {
  resource_group_name = azurerm_resource_group.rg_monitor.name
  workspace_id        = azurerm_log_analytics_workspace.la_monitor_log01.id
  read_access_id      = azurerm_automation_account.automation01.id

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Log Analytics Linked Service.

Microsoft.OperationalInsights/workspaces/linkedServices (Azure Resource Manager)

The workspaces/linkedServices in Microsoft.OperationalInsights can be configured in Azure Resource Manager with the resource name Microsoft.OperationalInsights/workspaces/linkedServices. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

depl-LogAnalytAzureAutom.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "logAnalyticsWorkspaceName": {
azuredeploy-automation.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
depl-LogAnalytAzureAutom.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "logAnalyticsWorkspaceName": {
loganalyticsWorkspace.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "rgLocation": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {
provisioningAutoAccOMSWorkspace.json
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "omsWorkspaceName": {

Frequently asked questions

What is Azure Log Analytics Linked Service?

Azure Log Analytics Linked Service is a resource for Log Analytics of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Log Analytics Linked Service?

For Terraform, the bytemech/tf_lz, Xergy/AzMIMDeploy and kevinhead/azurerm source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the sbkuehn/AzureOperations, mspnp/samples and sbkuehn/logAnalytics source code examples are useful. See the Azure Resource Manager Example section for further details.