last sync: 2021-Oct-15 16:53:12 UTC

Azure Policy definition

Configure API Management services to disable public network access

Name Configure API Management services to disable public network access
Azure Portal
Id 7ca8c8ac-3a6e-493d-99ba-c5fa35347ff2
Version 1.0.0
details on versioning
Category API Management
Microsoft docs
Description To improve the security of API Management services, disable public endpoints. Some public endpoints are exposed by API Management services to support user scenarios, e.g. direct access to Management API, managing configuration using Git, self-hosted gateways configuration. If any of those features are not used, corresponding endpoints should be disabled.
Mode Indexed
Type BuiltIn
Preview FALSE
Deprecated FALSE
Effect Default: DeployIfNotExists
Allowed: (DeployIfNotExists, Disabled)
Used RBAC Role
Role Name Role Id
API Management Service Contributor 312a565d-c81f-4fd8-895a-4e21e48d571c
History
Date/Time (UTC ymd) (i) Change type Change detail
2021-08-30 14:27:30 add 7ca8c8ac-3a6e-493d-99ba-c5fa35347ff2
Used in Initiatives none
JSON
{
  "displayName": "Configure API Management services to disable public network access",
  "policyType": "BuiltIn",
  "mode": "Indexed",
  "description": "To improve the security of API Management services, disable public endpoints. Some public endpoints are exposed by API Management services to support user scenarios, e.g. direct access to Management API, managing configuration using Git, self-hosted gateways configuration. If any of those features are not used, corresponding endpoints should be disabled.",
  "metadata": {
    "version": "1.0.0",
    "category": "API Management"
  },
  "parameters": {
    "effect": {
      "type": "String",
      "metadata": {
        "displayName": "Effect",
        "description": "Enable or disable the execution of the policy"
      },
      "allowedValues": [
        "DeployIfNotExists",
        "Disabled"
      ],
      "defaultValue": "DeployIfNotExists"
    },
    "endpointType": {
      "type": "String",
      "metadata": {
        "displayName": "Public Endpoint Type",
        "description": "Public Endpoint Type for which to enforce the access check"
      },
      "allowedValues": [
        "Management",
        "Git",
        "Gateway Configuration"
      ],
      "defaultValue": "Management"
    }
  },
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.ApiManagement/service"
        },
        {
          "field": "Microsoft.ApiManagement/service/sku.name",
          "notEquals": "Consumption"
        }
      ]
    },
    "then": {
      "effect": "[parameters('effect')]",
      "details": {
        "type": "Microsoft.ApiManagement/service/tenant",
        "name": "[if(equals(parameters('endpointType'), 'Management'), 'access', if(equals(parameters('endpointType'), 'Git'), 'gitaccess', 'gatewayaccess'))]",
        "evaluationDelay": "AfterProvisioningSuccess",
        "roleDefinitionIds": [
          "/providers/microsoft.authorization/roleDefinitions/312a565d-c81f-4fd8-895a-4e21e48d571c"
        ],
        "existenceCondition": {
          "field": "Microsoft.ApiManagement/service/tenant/enabled",
          "equals": false
        },
        "deployment": {
          "properties": {
            "mode": "incremental",
            "template": {
              "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
              "contentVersion": "1.0.0.0",
              "parameters": {
                "endpointType": {
                  "type": "string"
                },
                "apimName": {
                  "type": "string"
                }
              },
              "resources": [
                {
                  "name": "[concat(parameters('apimName'), '/', parameters('endpointType'))]",
                  "type": "Microsoft.ApiManagement/service/tenant",
                  "apiVersion": "2020-06-01-preview",
                  "properties": {
                    "enabled": false
                  }
                }
              ]
            },
            "parameters": {
              "endpointType": {
                "value": "[if(equals(parameters('endpointType'), 'Management'), 'access', if(equals(parameters('endpointType'), 'Git'), 'gitaccess', 'gatewayaccess'))]"
              },
              "apimName": {
                "value": "[field('name')]"
              }
            }
          }
        }
      }
    }
  }
}