Bylaw

Gallery › Monitoring › Azure built-in policies

Configure Azure Log Analytics workspaces to disable public network access for log ingestion and querying

Converted Policy Disabled Modify Mode Indexed Version 1.1.0

Improve workspace security by blocking log ingestion and querying from public networks. Only private-link connected networks will be able to ingest and query logs on this workspace. Learn more at https://aka.ms/AzMonPrivateLink#configure-log-analytics.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONLogAnalyticsWorkspaces_NetworkAccessEnabled_Modify.json · 75 lines
{
  "properties": {
    "displayName": "Configure Azure Log Analytics workspaces to disable public network access for log ingestion and querying",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Improve workspace security by blocking log ingestion and querying from public networks. Only private-link connected networks will be able to ingest and query logs on this workspace. Learn more at https://aka.ms/AzMonPrivateLink#configure-log-analytics.",
    "metadata": {
      "version": "1.1.0",
      "category": "Monitoring"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.OperationalInsights/workspaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.OperationalInsights/workspaces/publicNetworkAccessForIngestion",
                "notEquals": "Disabled"
              },
              {
                "field": "Microsoft.OperationalInsights/workspaces/publicNetworkAccessForQuery",
                "notEquals": "Disabled"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
          ],
          "conflictEffect": "Audit",
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "Microsoft.OperationalInsights/workspaces/publicNetworkAccessForIngestion",
              "value": "Disabled"
            },
            {
              "operation": "addOrReplace",
              "field": "Microsoft.OperationalInsights/workspaces/publicNetworkAccessForQuery",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/d3ba9c42-9dd5-441a-957c-274031c750c0",
  "name": "d3ba9c42-9dd5-441a-957c-274031c750c0"
}
Bylawd3ba9c42-9dd5-441a-957c-274031c750c0.bylaw.ps1 · 35 lines
# Converted from LogAnalyticsWorkspaces_NetworkAccessEnabled_Modify.json by ConvertTo-Bylaw.
Policy 'd3ba9c42-9dd5-441a-957c-274031c750c0' {

    Properties @{
        DisplayName   = 'Configure Azure Log Analytics workspaces to disable public network access for log ingestion and querying'
        Description   = 'Improve workspace security by blocking log ingestion and querying from public networks. Only private-link connected networks will be able to ingest and query logs on this workspace. Learn more at https://aka.ms/AzMonPrivateLink#configure-log-analytics.'
        Version       = '1.1.0'
        Category      = 'Monitoring'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Modify', 'Disabled')
        Default       = 'Modify'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.OperationalInsights/workspaces' {

        Require 'publicNetworkAccessForIngestion is Disabled' {
            Field publicNetworkAccessForIngestion | Must -Be 'Disabled'
        }

        Require 'publicNetworkAccessForQuery is Disabled' {
            Field publicNetworkAccessForQuery | Must -Be 'Disabled'
        }
    }

    Modify -Role 'Log Analytics Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccessForIngestion | AddOrReplace 'Disabled'
        Field publicNetworkAccessForQuery | AddOrReplace 'Disabled'
    }
}

Source: built-in-policies/policyDefinitions/Monitoring/LogAnalyticsWorkspaces_NetworkAccessEnabled_Modify.json in Azure/azure-policy, under the MIT licence.