Bylaw

Gallery › Compute › Azure Community Policy

Audit use of classic virtual machines

Converted Policy Audit Disabled Mode All Version 1.0.0

Use new Azure Resource Manager v2 for your virtual machines to provide security enhancements such as: stronger access control (RBAC), better auditing, ARM-based deployment and governance, access to managed identities, access to key vault for secrets, Azure AD-based authentication and support for tags and resource groups for easier security management

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

Azure Policy JSONazurepolicy.json · 36 lines
{
  "name": "9e08a937-bf18-436a-b14b-da18e7475012",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Audit use of classic virtual machines",
    "description": "Use new Azure Resource Manager v2 for your virtual machines to provide security enhancements such as: stronger access control (RBAC), better auditing, ARM-based deployment and governance, access to managed identities, access to key vault for secrets, Azure AD-based authentication and support for tags and resource groups for easier security management",
    "metadata": {
      "category": "Compute",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.classicCompute/virtualMachines"
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw9e08a937-bf18-436a-b14b-da18e7475012.bylaw.ps1 · 22 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '9e08a937-bf18-436a-b14b-da18e7475012' {

    Properties @{
        DisplayName = 'Audit use of classic virtual machines'
        Description = 'Use new Azure Resource Manager v2 for your virtual machines to provide security enhancements such as: stronger access control (RBAC), better auditing, ARM-based deployment and governance, access to managed identities, access to key vault for secrets, Azure AD-based authentication and support for tags and resource groups for easier security management'
        Category    = 'Compute'
        Version     = '1.0.0'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.classicCompute/virtualMachines'

    Effect (Param Effect)
}

Source: policyDefinitions/Compute/audit-use-of-classic-virtual-machines/azurepolicy.json in Azure/Community-Policy, under the MIT licence.