Bylaw

Gallery › Managed Grafana › Azure built-in policies

Configure Azure Managed Grafana workspaces to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

Disable public network access for your Azure Managed Grafana workspace so that it's not accessible over the public internet. This can reduce data leakage risks.

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

Azure Policy JSONAMG_PublicNetworkAccess_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Configure Azure Managed Grafana workspaces to disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable public network access for your Azure Managed Grafana workspace so that it's not accessible over the public internet. This can reduce data leakage risks.",
    "metadata": {
      "version": "1.0.0",
      "category": "Managed Grafana"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Dashboard/grafana"
          },
          {
            "field": "Microsoft.Dashboard/grafana/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "conflictEffect": "audit",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "operations": [
            {
              "condition": "[greaterOrEquals(requestContext().apiVersion, '2022-10-01-preview')]",
              "operation": "addOrReplace",
              "field": "Microsoft.Dashboard/grafana/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/67529aa1-5285-4b1c-8e6f-5ccd861ac98e",
  "name": "67529aa1-5285-4b1c-8e6f-5ccd861ac98e"
}
Bylaw67529aa1-5285-4b1c-8e6f-5ccd861ac98e.bylaw.ps1 · 30 lines
# Converted from AMG_PublicNetworkAccess_Modify.json by ConvertTo-Bylaw.
Policy '67529aa1-5285-4b1c-8e6f-5ccd861ac98e' {

    Properties @{
        DisplayName   = 'Configure Azure Managed Grafana workspaces to disable public network access'
        Description   = 'Disable public network access for your Azure Managed Grafana workspace so that it''s not accessible over the public internet. This can reduce data leakage risks.'
        Version       = '1.0.0'
        Category      = 'Managed Grafana'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Modify', 'Disabled')
        Default       = 'Modify'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Dashboard/grafana' {

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

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled' -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2022-10-01-preview'')]')
    }
}

Source: built-in-policies/policyDefinitions/Managed Grafana/AMG_PublicNetworkAccess_Modify.json in Azure/azure-policy, under the MIT licence.