Bylaw

Gallery › DevCenter › Azure built-in policies

[Preview]: Microsoft Dev Box Pools should not use Microsoft Hosted Networks.

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview

Disallows the use of Microsoft Hosted Networks when creating Pool resources.

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

Azure Policy JSONMicrosoftHostedNetworks_Audit.json · 51 lines
{
  "properties": {
    "displayName": "[Preview]: Microsoft Dev Box Pools should not use Microsoft Hosted Networks.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disallows the use of Microsoft Hosted Networks when creating Pool resources.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "DevCenter",
      "preview": true
    },
    "version": "1.0.0-preview",
    "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.DevCenter/projects/pools"
          },
          {
            "field": "Microsoft.DevCenter/projects/pools/virtualNetworkType",
            "equals": "Managed"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/ece3c79b-2caf-470d-a5f5-66470c4fc649",
  "name": "ece3c79b-2caf-470d-a5f5-66470c4fc649"
}
Bylawece3c79b-2caf-470d-a5f5-66470c4fc649.bylaw.ps1 · 29 lines
# Converted from MicrosoftHostedNetworks_Audit.json by ConvertTo-Bylaw.
Policy 'ece3c79b-2caf-470d-a5f5-66470c4fc649' {

    Properties @{
        DisplayName   = '[Preview]: Microsoft Dev Box Pools should not use Microsoft Hosted Networks.'
        Description   = 'Disallows the use of Microsoft Hosted Networks when creating Pool resources.'
        Version       = '1.0.0-preview'
        Category      = 'DevCenter'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.DevCenter/projects/pools' {

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/DevCenter/MicrosoftHostedNetworks_Audit.json in Azure/azure-policy, under the MIT licence.