Bylaw

Gallery › Container Apps › Azure built-in policies

Container Apps should disable external network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Disable external network access to your Container Apps by enforcing internal-only ingress. This will ensure inbound communication for Container Apps is limited to callers within the Container Apps environment.

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

Azure Policy JSONContainerAppInternal_Audit.json · 51 lines
{
  "properties": {
    "displayName": "Container Apps should disable external network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable external network access to your Container Apps by enforcing internal-only ingress. This will ensure inbound communication for Container Apps is limited to callers within the Container Apps environment.",
    "metadata": {
      "version": "1.1.0",
      "category": "Container Apps"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.App/containerApps"
          },
          {
            "field": "Microsoft.App/containerApps/configuration.ingress.external",
            "equals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/783ea2a8-b8fd-46be-896a-9ae79643a0b1",
  "name": "783ea2a8-b8fd-46be-896a-9ae79643a0b1"
}
Bylaw783ea2a8-b8fd-46be-896a-9ae79643a0b1.bylaw.ps1 · 28 lines
# Converted from ContainerAppInternal_Audit.json by ConvertTo-Bylaw.
Policy '783ea2a8-b8fd-46be-896a-9ae79643a0b1' {

    Properties @{
        DisplayName   = 'Container Apps should disable external network access'
        Description   = 'Disable external network access to your Container Apps by enforcing internal-only ingress. This will ensure inbound communication for Container Apps is limited to callers within the Container Apps environment.'
        Version       = '1.1.0'
        Category      = 'Container Apps'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.App/containerApps' {

        Require 'configuration.ingress.external is not true' {
            Field configuration.ingress.external | Must -Not -Be $true -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Container Apps/ContainerAppInternal_Audit.json in Azure/azure-policy, under the MIT licence.