Bylaw

Gallery › App Platform › Azure built-in policies

Azure Spring Cloud should use network injection

Converted Policy Audit Deny Disabled Mode Indexed Version 1.2.0

Azure Spring Cloud instances should use virtual network injection for the following purposes: 1. Isolate Azure Spring Cloud from Internet. 2. Enable Azure Spring Cloud to interact with systems in either on premises data centers or Azure service in other virtual networks. 3. Empower customers to control inbound and outbound network communications for Azure Spring Cloud.

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

Azure Policy JSONSpring_VNETEnabled_Audit.json · 69 lines
{
  "properties": {
    "displayName": "Azure Spring Cloud should use network injection",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Spring Cloud instances should use virtual network injection for the following purposes: 1. Isolate Azure Spring Cloud from Internet. 2. Enable Azure Spring Cloud to interact with systems in either on premises data centers or Azure service in other virtual networks. 3. Empower customers to control inbound and outbound network communications for Azure Spring Cloud.",
    "metadata": {
      "version": "1.2.0",
      "category": "App Platform"
    },
    "version": "1.2.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled",
          "Deny"
        ],
        "defaultValue": "Audit"
      },
      "evaluatedSkuNames": {
        "type": "Array",
        "metadata": {
          "displayName": "Azure Spring Cloud SKU Names",
          "description": "List of Azure Spring Cloud SKUs against which this policy will be evaluated."
        },
        "allowedValues": [
          "Standard",
          "Enterprise"
        ],
        "defaultValue": [
          "Standard",
          "Enterprise"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.AppPlatform/Spring"
          },
          {
            "field": "Microsoft.AppPlatform/Spring/sku.tier",
            "in": "[parameters('evaluatedSkuNames')]"
          },
          {
            "field": "Microsoft.AppPlatform/Spring/networkProfile.serviceRuntimeSubnetId",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.2.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/af35e2a4-ef96-44e7-a9ae-853dd97032c4",
  "name": "af35e2a4-ef96-44e7-a9ae-853dd97032c4"
}
Bylawaf35e2a4-ef96-44e7-a9ae-853dd97032c4.bylaw.ps1 · 39 lines
# Converted from Spring_VNETEnabled_Audit.json by ConvertTo-Bylaw.
Policy 'af35e2a4-ef96-44e7-a9ae-853dd97032c4' {

    Properties @{
        DisplayName   = 'Azure Spring Cloud should use network injection'
        Description   = 'Azure Spring Cloud instances should use virtual network injection for the following purposes: 1. Isolate Azure Spring Cloud from Internet. 2. Enable Azure Spring Cloud to interact with systems in either on premises data centers or Azure service in other virtual networks. 3. Empower customers to control inbound and outbound network communications for Azure Spring Cloud.'
        Version       = '1.2.0'
        Category      = 'App Platform'
        PolicyVersion = '1.2.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled', 'Deny')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter EvaluatedSkuNames @{
        Type          = 'Array'
        AllowedValues = @('Standard', 'Enterprise')
        Default       = @('Standard', 'Enterprise')
        DisplayName   = 'Azure Spring Cloud SKU Names'
        Description   = 'List of Azure Spring Cloud SKUs against which this policy will be evaluated.'
    }

    Resource 'Microsoft.AppPlatform/Spring' {

        When {
            Field sku.tier | Must -BeIn (Param EvaluatedSkuNames)
        }

        Require 'networkProfile.serviceRuntimeSubnetId exists' {
            Field networkProfile.serviceRuntimeSubnetId | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/App Platform/Spring_VNETEnabled_Audit.json in Azure/azure-policy, under the MIT licence.