Bylaw

Gallery › Container Apps › Azure built-in policies

Container Apps environment should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Disable public network access to improve security by exposing the Container Apps environment through an internal load balancer. This removes the need for a public IP address and prevents internet access to all Container Apps within the environment.

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

Azure Policy JSONEnvironmentInternal_Audit.json · 63 lines
{
  "properties": {
    "displayName": "Container Apps environment should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable public network access to improve security by exposing the Container Apps environment through an internal load balancer. This removes the need for a public IP address and prevents internet access to all Container Apps within the 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/managedEnvironments"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.App/managedEnvironments/vnetConfiguration",
                "exists": false
              },
              {
                "field": "Microsoft.App/managedEnvironments/vnetConfiguration.internal",
                "exists": false
              },
              {
                "field": "Microsoft.App/managedEnvironments/vnetConfiguration.internal",
                "equals": false
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/d074ddf8-01a5-4b5e-a2b8-964aed452c0a",
  "name": "d074ddf8-01a5-4b5e-a2b8-964aed452c0a"
}
Bylawd074ddf8-01a5-4b5e-a2b8-964aed452c0a.bylaw.ps1 · 36 lines
# Converted from EnvironmentInternal_Audit.json by ConvertTo-Bylaw.
Policy 'd074ddf8-01a5-4b5e-a2b8-964aed452c0a' {

    Properties @{
        DisplayName   = 'Container Apps environment should disable public network access'
        Description   = 'Disable public network access to improve security by exposing the Container Apps environment through an internal load balancer. This removes the need for a public IP address and prevents internet access to all Container Apps within the 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/managedEnvironments' {

        Require 'vnetConfiguration exists' {
            Field vnetConfiguration | Must -Exist
        }

        Require 'vnetConfiguration.internal exists' {
            Field vnetConfiguration.internal | Must -Exist
        }

        Require 'vnetConfiguration.internal is not false' {
            Field vnetConfiguration.internal | Must -Not -Be $false -IfPresent
        }
    }

    Effect (Param Effect)
}

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