Bylaw

Gallery › Mission › Azure built-in policies

Configure managed disk network access policy to deny all

Converted Policy Disabled Modify Mode All Version 1.0.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Compute policy enforces that Managed Disks cannot be exported.

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

Azure Policy JSONComputeDenyDiskExport_Modify.json · 61 lines
{
  "properties": {
    "displayName": "Configure managed disk network access policy to deny all",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Compute policy enforces that Managed Disks cannot be exported.",
    "metadata": {
      "version": "1.0.0",
      "category": "Mission"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/disks"
          },
          {
            "field": "Microsoft.Compute/disks/networkAccessPolicy",
            "notEquals": "DenyAll"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "Microsoft.Compute/disks/networkAccessPolicy",
              "value": "DenyAll"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f4273bc9-d20e-438d-ad30-b72221939edc",
  "name": "f4273bc9-d20e-438d-ad30-b72221939edc"
}
Bylawf4273bc9-d20e-438d-ad30-b72221939edc.bylaw.ps1 · 30 lines
# Converted from ComputeDenyDiskExport_Modify.json by ConvertTo-Bylaw.
Policy 'f4273bc9-d20e-438d-ad30-b72221939edc' {

    Properties @{
        DisplayName   = 'Configure managed disk network access policy to deny all'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Compute policy enforces that Managed Disks cannot be exported.'
        Version       = '1.0.0'
        Category      = 'Mission'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Compute/disks' {

        Require 'networkAccessPolicy is DenyAll' {
            Field networkAccessPolicy | Must -Be 'DenyAll'
        }
    }

    Modify -Role 'Contributor' -Effect (Param Effect) {
        Field networkAccessPolicy | AddOrReplace 'DenyAll'
    }
}

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