Bylaw

Gallery › Playwright Workspaces › Azure built-in policies

Playwright Workspaces should use virtual network injection

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Require Playwright Workspaces to specify a subnet for virtual network injection. This enables cloud-hosted browsers to access applications on private networks and allows network traffic to be controlled through the virtual network. The subnet cannot be changed after workspace creation; existing workspaces without a subnet must be recreated to comply.

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

Azure Policy JSONWorkspace_NetworkIsolation_Audit.json · 58 lines
{
  "properties": {
    "displayName": "Playwright Workspaces should use virtual network injection",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Require Playwright Workspaces to specify a subnet for virtual network injection. This enables cloud-hosted browsers to access applications on private networks and allows network traffic to be controlled through the virtual network. The subnet cannot be changed after workspace creation; existing workspaces without a subnet must be recreated to comply.",
    "metadata": {
      "version": "1.0.0",
      "category": "Playwright Workspaces"
    },
    "version": "1.0.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.LoadTestService/playwrightWorkspaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.LoadTestService/playwrightWorkspaces/subnetId",
                "exists": "false"
              },
              {
                "field": "Microsoft.LoadTestService/playwrightWorkspaces/subnetId",
                "equals": ""
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f241cc0d-68e6-413b-8235-f7490ef17294",
  "name": "f241cc0d-68e6-413b-8235-f7490ef17294"
}
Bylawf241cc0d-68e6-413b-8235-f7490ef17294.bylaw.ps1 · 32 lines
# Converted from Workspace_NetworkIsolation_Audit.json by ConvertTo-Bylaw.
Policy 'f241cc0d-68e6-413b-8235-f7490ef17294' {

    Properties @{
        DisplayName   = 'Playwright Workspaces should use virtual network injection'
        Description   = 'Require Playwright Workspaces to specify a subnet for virtual network injection. This enables cloud-hosted browsers to access applications on private networks and allows network traffic to be controlled through the virtual network. The subnet cannot be changed after workspace creation; existing workspaces without a subnet must be recreated to comply.'
        Version       = '1.0.0'
        Category      = 'Playwright Workspaces'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.LoadTestService/playwrightWorkspaces' {

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

        Require 'subnetId is not' {
            Field subnetId | Must -Not -Be '' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Playwright Workspaces/Workspace_NetworkIsolation_Audit.json in Azure/azure-policy, under the MIT licence.